<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0051)http://blog.csdn.net/hguisu/article/details/6155636 -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script async="" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/alog.mobile.min.js"></script>    
    <script type="text/javascript" async="" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ga.js"></script><script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/tracking.js" charset="utf-8"></script>  

    <script type="text/javascript">
        var protocol = window.location.protocol;
        document.write('<script type="text/javascript" src="' + protocol + '//csdnimg.cn/pubfooter/js/repoAddr2.js?v=' + Math.random() + '"></' + 'script>');
    </script><script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/repoAddr2.js"></script>

     <script id="allmobilize" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/allmobilize.min.js"></script><style type="text/css"></style>
 <meta http-equiv="Cache-Control" content="no-siteapp"><link rel="alternate" media="handheld" href="http://blog.csdn.net/hguisu/article/details/6155636#">

    <title>深入理解java异常处理机制 - guisu，程序人生。  逆水行舟，不进则退。
        - 博客频道 - CSDN.NET</title>
    
    <meta name="description" content="1. 引子       try…catch…finally恐怕是大家再熟悉不过的语句了，而且感觉用起来也是很简单，逻辑上似乎也是很容易理解。不过，我亲自体验的“教训”告诉我，这个东西可不是想象中的那么简单、听话。不信？那你看看下面的代码，“猜猜”它执行后的结果会是什么？不要往后看答案、也不许执行代码看真正答案哦。如果你的答案是正确，那么这篇文章你就不用浪费时间看啦。pa">
    <script src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad.js"></script>
        <!--new top-->
       
        <link rel="stylesheet" href="http://static.csdn.net/public/common/toolbar/css/index.css">
        <!--new top-->

    <link rel="Stylesheet" type="text/css" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/style.css">
    <link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="http://blog.csdn.net/hguisu/rss/list">
    <link rel="shortcut icon" href="http://c.csdnimg.cn/public/favicon.ico">
    <link type="text/css" rel="stylesheet" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/simple.css">
 


<script src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/share.js"></script><style type="text/css">.MathJax_Hover_Frame {border-radius: .25em; -webkit-border-radius: .25em; -moz-border-radius: .25em; -khtml-border-radius: .25em; box-shadow: 0px 0px 15px #83A; -webkit-box-shadow: 0px 0px 15px #83A; -moz-box-shadow: 0px 0px 15px #83A; -khtml-box-shadow: 0px 0px 15px #83A; border: 1px solid #A6D ! important; display: inline-block; position: absolute}
.MathJax_Hover_Arrow {position: absolute; width: 15px; height: 11px; cursor: pointer}
</style><style type="text/css">#MathJax_About {position: fixed; left: 50%; width: auto; text-align: center; border: 3px outset; padding: 1em 2em; background-color: #DDDDDD; color: black; cursor: default; font-family: message-box; font-size: 120%; font-style: normal; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -khtml-border-radius: 15px; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
.MathJax_Menu {position: absolute; background-color: white; color: black; width: auto; padding: 5px 0px; border: 1px solid #CCCCCC; margin: 0; cursor: default; font: menu; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -khtml-border-radius: 5px; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
.MathJax_MenuItem {padding: 1px 2em; background: transparent}
.MathJax_MenuArrow {position: absolute; right: .5em; color: #666666}
.MathJax_MenuActive .MathJax_MenuArrow {color: white}
.MathJax_MenuArrow.RTL {left: .5em; right: auto}
.MathJax_MenuCheck {position: absolute; left: .7em}
.MathJax_MenuCheck.RTL {right: .7em; left: auto}
.MathJax_MenuRadioCheck {position: absolute; left: .7em}
.MathJax_MenuRadioCheck.RTL {right: .7em; left: auto}
.MathJax_MenuLabel {padding: 1px 2em 3px 1.33em; font-style: italic}
.MathJax_MenuRule {border-top: 1px solid #DDDDDD; margin: 4px 3px}
.MathJax_MenuDisabled {color: GrayText}
.MathJax_MenuActive {background-color: #606872; color: white}
.MathJax_Menu_Close {position: absolute; width: 31px; height: 31px; top: -15px; left: -15px}
</style><style type="text/css">#MathJax_Zoom {position: absolute; background-color: #F0F0F0; overflow: auto; display: block; z-index: 301; padding: .5em; border: 1px solid black; margin: 0; font-weight: normal; font-style: normal; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; box-shadow: 5px 5px 15px #AAAAAA; -webkit-box-shadow: 5px 5px 15px #AAAAAA; -moz-box-shadow: 5px 5px 15px #AAAAAA; -khtml-box-shadow: 5px 5px 15px #AAAAAA; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
#MathJax_ZoomOverlay {position: absolute; left: 0; top: 0; z-index: 300; display: inline-block; width: 100%; height: 100%; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
#MathJax_ZoomFrame {position: relative; display: inline-block; height: 0; width: 0}
#MathJax_ZoomEventTrap {position: absolute; left: 0; top: 0; z-index: 302; display: inline-block; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
</style><style type="text/css">.MathJax_Preview {color: #888}
#MathJax_Message {position: fixed; left: 1em; bottom: 1.5em; background-color: #E6E6E6; border: 1px solid #959595; margin: 0px; padding: 2px 8px; z-index: 102; color: black; font-size: 80%; width: auto; white-space: nowrap}
#MathJax_MSIE_Frame {position: absolute; top: 0; left: 0; width: 0px; z-index: 101; border: 0px; margin: 0px; padding: 0px}
.MathJax_Error {color: #CC0000; font-style: italic}
</style><link rel="stylesheet" type="text/css" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/job_reco.css"><link href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/bdsstyle.css" rel="stylesheet" type="text/css"><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/main.js"></script><script charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/lightapp.js" data-appid="3629560" async="" name="baidu-tc-cerfication"></script><link rel="stylesheet" type="text/css" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/style(1).css"><link type="text/css" rel="stylesheet" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/style(2).css"><script src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/logger.js"></script><script src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/get" async="" type="text/javascript" charset="utf-8"></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/helper-utils-moplus-monitor_100e0a8.js" _md_="_anymoore_http://apps.bdimg.com/cloudaapi/pkg/helper-utils-moplus-monitor_100e0a8.js"></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/push-smartBar_63a6378.js" _md_="_anymoore_http://apps.bdimg.com/cloudaapi/pkg/push-smartBar_63a6378.js"></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/app-socialshare_3d15544.js" _md_="_anymoore_http://apps.bdimg.com/cloudaapi/pkg/app-socialshare_3d15544.js"></script><link rel="stylesheet" href="http://bdimg.share.baidu.com/static/api/css/share_style0_16.css?v=8105b07e.css"><script src="http://127.0.0.1:7777/weakBindLight?apikey=zGhG9os6hVZxp2KLek3cwIuM&nonce=HYa1f5Rxx3ISzsGg2Kqs&csrftoken=9dc192b35dd697ffbc070eaaf9ff8b8f&channel=clouda&callback=cloudaPushServiceWeakBindLight"></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/account-pay_6085eaa.js" _md_="_anymoore_http://apps.bdimg.com/cloudaapi/pkg/account-pay_6085eaa.js"></script></head>
<body class=" hPC" style="padding-bottom: 45px;"><div id="MathJax_Message" style="display: none;"></div><iframe frameborder="0" style="display: none;"></iframe>
    
   
      <!--new top-->
    <script id="toolbar-tpl-scriptId" fixed="true" prod="blog" skin="black" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/html.js" type="text/javascript"></script><div class="csdn-toolbar csdn-toolbar-skin-black ">        <div class="container row center-block ">          <div class="col-md-3 pull-left logo clearfix"><a href="http://www.csdn.net/?ref=toolbar" title="CSDN首页" target="_blank" class="icon"></a><a title="频道首页" href="http://blog.csdn.net/?ref=toolbar_logo" target="_blank" class="img blog-icon"></a></div>          <div class="pull-right login-wrap unlogin">            <ul class="btns">              <li class="loginlink"><a href="https://passport.csdn.net/account/login?ref=toolbar" target="_top">登录&nbsp;</a>|<a target="_top" href="https://passport.csdn.net/account/register?ref=toolbar">&nbsp;注册</a></li>              <li class="search">                <div class="icon on-search-icon">                  <div class="wrap">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                    <form action="http://so.csdn.net/search" method="get" target="_blank">                      <input type="hidden" value="toolbar" name="ref" accesskey="2">                      <div class="border">                        <input placeholder="搜索" type="text" value="" name="q" accesskey="2"><span class="icon-enter-sm"></span>                      </div>                    </form>                  </div>                </div>              </li>              <li class="favor">                <div class="icon on-favor-icon">                  <div class="wrap">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                    <div style="display:none;" class="favor-success"><span class="msg">收藏成功</span>                      <div class="btns"><span class="btn btn-primary ok">确定</span></div>                    </div>                    <div style="display:none;" class="favor-failed"><span class="icon-danger-lg"></span><span class="msg">收藏失败，请重新收藏</span>                      <div class="btns"><span class="btn btn-primary ok">确定</span></div>                    </div>                    <form role="form" class="form-horizontal favor-form">                      <div class="form-group">                        <div class="clearfix">                          <label for="input-title" class="col-sm-2 control-label">标题</label>                          <div class="col-sm-10">                            <input id="inputTitle" type="text" placeholder="" class="title form-control">                          </div>                        </div>                        <div class="alert alert-danger"><strong></strong>标题不能为空</div>                      </div>                      <div class="form-group">                        <label for="input-url" class="col-sm-2 control-label">网址</label>                        <div class="col-sm-10">                          <input id="input-url" type="text" placeholder="" class="url form-control">                        </div>                      </div>                      <div class="form-group">                        <label for="input-tag" class="col-sm-2 tag control-label">标签</label>                        <div class="col-sm-10">                          <input id="input-tag" type="text" class="form-control tag">                        </div>                      </div>                      <div class="form-group">                        <label for="input-description" class="description col-sm-2 control-label">摘要</label>                        <div class="col-sm-10">                          <textarea id="input-description" class="form-control description"></textarea>                        </div>                      </div>                      <div class="form-group">                        <div class="col-sm-offset-2 col-sm-10 ft">                          <div class="col-sm-4 pull-left">                            <div class="checkbox">                              <label>                                <input type="checkbox" name="share" checked="checked" class="share">公开                              </label>                            </div>                          </div>                          <div class="col-sm-8 pull-right favor-btns">                            <button type="button" class="cancel btn btn-default">取消</button>                            <button type="submit" class="submit btn btn-primary">收藏</button>                          </div>                        </div>                      </div>                    </form>                  </div>                </div>              </li>              <li class="notify">                <div style="display:none" class="number"></div>                <div style="display:none" class="icon-hasnotes-sm"></div>                <div id="header_notice_num"></div>                <div class="icon on-notify-icon">                  <div class="wrap">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                    <div id="note1" class="csdn_note">                      <div class="box"></div>                    <iframe src="about:block" frameborder="0" allowtransparency="true" style="z-index:-1;position:absolute;top:0;left:0;width:100%;height:100%;background:transparent"></iframe></div>                  </div>                </div>              </li>              <li class="ugc">                <div class="icon on-ugc-icon">                  <div class="wrap clearfix">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                    <dl>                      <dt><a href="http://geek.csdn.net/news/expert?ref=toolbar" target="_blank" class="p-news clearfix"><em class="icon"></em><span>分享资讯</span></a></dt>                      <dt><a href="http://share.csdn.net/slides/new?ref=toolbar" target="_blank" class="p-doc clearfix"><em class="icon"></em><span>传PPT/文档</span></a></dt>                      <dt><a href="http://bbs.csdn.net/topics/new?ref=toolbar" target="_blank" class="p-ask clearfix"><em class="icon"></em><span>提问题</span></a></dt>                      <dt><a href="http://write.blog.csdn.net/postedit?ref=toolbar" target="_blank" class="p-blog clearfix"><em class="icon"></em><span>写博客</span></a></dt>                      <dt><a href="http://u.download.csdn.net/upload?ref=toolbar" target="_blank" class="p-src clearfix"><em class="icon"></em><span>传资源</span></a></dt>                      <dt><a href="https://code.csdn.net/projects/new?ref=toolbar" target="_blank" class="c-obj clearfix"><em class="icon"></em><span>创建项目</span></a></dt>                      <dt><a href="https://code.csdn.net/snippets/new?ref=toolbar" target="_blank" class="c-code clearfix"><em class="icon"></em><span>创建代码片</span></a></dt>                    </dl>                  </div>                </div>              </li>              <li class="profile">                <div class="icon on-profile-icon"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/100x100.jpg" class="curr-icon-img">                  <div class="wrap clearfix">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                    <div class="bd">                      <dl class="clearfix">                        <dt class="pull-left img"><a target="_blank" href="http://my.csdn.net/?ref=toolbar" class="avatar"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/100x100.jpg"></a></dt>                        <dd class="info" style="border: none;"><a target="_blank" href="http://my.csdn.net/?ref=toolbar" class="nickname"></a><a class="set-nick" href="https://passport.csdn.net/account/profile">设置昵称<span class="write-icon"></span></a><span class="dec"><a class="fill-dec" href="http://my.csdn.net/" target="_blank">编辑自我介绍，让更多人了解你<span class="write-icon"></span></a></span></dd>                      </dl>                    </div>                    <div class="ft clearfix"><a target="_blank" href="http://my.csdn.net/my/account/changepwd?ref=toolbar" class="pull-left"><span class="icon-cog"></span>帐号设置</a><a href="https://passport.csdn.net/account/logout?ref=toolbar" target="_top" class="pull-left" style="margin-left:132px; width:18px; height:27px; white-space:nowrap; overflow:hidden;"><span class="icon-signout"></span><span class="out">退出</span></a></div>                  </div>                </div>              </li>              <li class="apps">                <div id="chasnew123" class="hasnew" style="display: none;"></div>                <div id="cappsarea123" class="icon on-apps-icon">                  <div class="wrap clearfix">                    <div class="curr-icon-wrap">                      <div class="curr-icon"></div>                    </div>                  <div class="detail">                    <dl>                      <dt>                        <h5>社区</h5>                      </dt>                      <dd> <a href="http://blog.csdn.net/?ref=toolbar" target="_blank">博客</a></dd>                      <dd> <a href="http://bbs.csdn.net/?ref=toolbar" target="_blank">论坛</a></dd>                      <dd> <a href="http://download.csdn.net/?ref=toolbar" target="_blank">下载</a></dd>                      <dd><a href="http://ask.csdn.net/?ref=toolbar" target="_blank">技术问答</a></dd>                      <dd><a href="http://geek.csdn.net/?ref=toolbar" target="_blank">极客头条</a></dd>                      <dd> <a href="http://hero.csdn.net/?ref=toolbar" target="_blank">英雄会</a></dd>                    </dl>                  </div>                  <div class="detail">                    <dl>                      <dt>                        <h5>服务</h5>                      </dt>                      <dd> <a href="http://job.csdn.net/?ref=toolbar" target="_blank">JOB<img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/new.gif" style="margin-top: -26px; width: 23px;"></a></dd>                      <dd> <a href="http://edu.csdn.net/?ref=toolbar" target="_blank">学院<img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/new.gif" style="margin-top: -26px; width: 23px;"></a></dd>                      <dd> <a href="https://code.csdn.net/?ref=toolbar" target="_blank">CODE</a></dd>                      <dd> <a href="http://huiyi.csdn.net/?ref=toolbar" target="_blank">活动</a></dd>                      <dd> <a href="http://www.csto.com/?ref=toolbar" target="_blank">CSTO</a></dd>                      <dd> <a href="http://mall.csdn.net/?ref=toolbar" target="_blank">C币兑换<img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/new.gif" style="margin-top: -26px; width: 23px;"></a></dd>                    </dl>                  </div>                  <div class="detail last">                    <dl>                      <dt>                        <h5>俱乐部</h5>                      </dt>                      <dd> <a href="http://cto.csdn.net/?ref=toolbar" target="_blank">CTO俱乐部</a></dd>                      <dd> <a href="http://student.csdn.net/?ref=toolbar" target="_blank">高校俱乐部</a></dd>                    </dl>                  </div>                </div>              </div>            </li>            </ul>          </div>        </div>    </div>
     <!--new top-->
    <div id="container">
        <div id="header">
    <div class="header">
        <div id="blog_title">
            <h2>
                <a href="http://blog.csdn.net/hguisu">guisu，程序人生。  逆水行舟，不进则退。</a></h2>
            <h3>能干的人解决问题。智慧的人绕开问题(A clever person solves a problem. A wise person avoids it)</h3>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>
            
                <li id="btnContents"><a href="http://blog.csdn.net/hguisu?viewmode=contents"><span onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_mulu&#39;])">
                    <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_list.gif">目录视图</span></a></li>
                <li id="btnView"><a href="http://blog.csdn.net/hguisu?viewmode=list"><span onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_zhaiyao&#39;])">
                    <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_summary.gif">摘要视图</span></a></li>
                <li id="btnRss"><a href="http://blog.csdn.net/hguisu/rss/list"><span onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_RSS&#39;])">
                    <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_rss.gif">订阅</span></a></li>                

            </ul>
    </div>
</div>
<script type="text/javascript">
    var username = "hguisu";
    var _blogger = username;
    var blog_address = "http://blog.csdn.net/hguisu";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = "";  
</script>

        <div id="body">
            <div id="main">
                <div class="main">
                        <div class="ad_class">
<div class="notice tracking-ad" data-mod="popu_3"> 

<a href="http://blog.csdn.net/csdnedu/article/details/43306129" target="_blank">
<font color="blue">CSDN学院讲师招募</font></a>
&nbsp;&nbsp;&nbsp;



<a href="http://blog.csdn.net/csdnproduct/article/details/43561659" target="_blank">
<font color="red">Markdown编辑器轻松写博文</font></a>
&nbsp;&nbsp;&nbsp;



<a href="http://job.csdn.net/event/zpweb/index.html" target="_blank">
<font color="blue">TOP 50 CTO坐镇直招
</font></a>
&nbsp;&nbsp;&nbsp;




<a href="http://blog.csdn.net/blogdevteam/article/details/44561379" target="_blank">
<font color="red">读文章说感想获好礼
</font></a>
&nbsp;&nbsp;&nbsp;



</div>                        </div>
                        

  
<link href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/comment1.css" type="text/css" rel="stylesheet">
<link href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/style1.css" type="text/css" rel="stylesheet">
<script language="JavaScript" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/jquery.cookie.js"></script>
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/main(1).js"></script>


<link rel="stylesheet" href="http://static.blog.csdn.net/public/res-min/markdown_views.css?v=1.0">

<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/MathJax.js"></script>









  <script type="text/ecmascript">
      window.quickReplyflag = true;
    </script>
<div id="article_details" class="details">
    <div class="article_title">   
         <span class="ico ico_type_Original"></span>


    <h1>
        <span class="link_title"><a href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET.html">
        深入理解java异常处理机制
        </a></span>
    </h1>
</div>

    <div class="article_manage">
        <span class="link_categories">
        分类：
            <a href="http://blog.csdn.net/hguisu/article/category/1114530" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_fenlei&#39;]);">Java</a> 
        </span>
    <span class="link_postdate">2011-01-20 18:44</span>
    <span class="link_view" title="阅读次数">41236人阅读</span>
    <span class="link_comments" title="评论次数"><a href="http://blog.csdn.net/hguisu/article/details/6155636#comments" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_pinglun&#39;])">评论</a>(40)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_shoucang&#39;]);collectArticle(&#39;深入理解java异常处理机制&#39;,&#39;6155636&#39;);return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="http://blog.csdn.net/hguisu/article/details/6155636#report" onclick="javascript:_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_jubao&#39;]);report(6155636,2);return false;" title="举报">举报</a></span>
    
</div>
<div class="tag2box"><a href="http://www.csdn.net/tag/file" target="_blank" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_tag&#39;]);">file</a><a href="http://www.csdn.net/tag/php" target="_blank" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_tag&#39;]);">php</a><a href="http://www.csdn.net/tag/ubuntu" target="_blank" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_tag&#39;]);">ubuntu</a><a href="http://www.csdn.net/tag/%e6%9c%8d%e5%8a%a1%e5%99%a8" target="_blank" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_tag&#39;]);">服务器</a><a href="http://www.csdn.net/tag/%e4%bb%bb%e5%8a%a1" target="_blank" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_tag&#39;]);">任务</a></div>

  
    
<div style="clear:both"></div><div style="border:solid 1px #ccc; background:#eee; float:left; min-width:200px;padding:4px 10px;"><p style="text-align:right;margin:0;"><span style="float:left;">目录<a href="http://blog.csdn.net/hguisu/article/details/6155636#" title="系统根据文章中H1到H6标签自动生成文章目录">(?)</a></span><a href="http://blog.csdn.net/hguisu/article/details/6155636#" onclick="javascript:return openct(this);" title="展开">[+]</a></p><ol style="display:none;margin-left:14px;padding-left:14px;line-height:160%;"><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t0">

&nbsp;1 引子
</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t1">

&nbsp;2JAVA异常
</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t2">

&nbsp;4处理异常机制
</a></li><ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t3">1 捕获异常trycatch 和 finally</a></li><ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t4">try-catch语句</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t5">trycatch-finally语句</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t6">try-catch-finally 规则异常处理语句的语法规则</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t7">trycatchfinally语句块的执行顺序</a></li></ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t8">2 抛出异常</a></li><ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t9">throws抛出异常</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t10">使用throw抛出异常</a></li></ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t11">4 Throwable类中的常用方法</a></li></ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t12">

&nbsp;5Java常见异常
</a></li><ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t13">runtimeException子类</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t14">IOException</a></li><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t15">其他</a></li></ol><li><a href="http://blog.csdn.net/hguisu/article/details/6155636#t16">

&nbsp;6自定义异常
</a></li></ol></div><div style="clear:both"></div><div id="article_content" class="article_content">

<p><strong></strong></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"></span></p>
<div>
<h2 style="margin:0px; padding:0px; color:rgb(51,51,51); font-family:Arial; line-height:26px; text-align:left"><a name="t0"></a>
<p class="headline-1 bk-sidecatalog-title" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:6px; border-bottom-color:rgb(222,223,225); border-bottom-width:1px; border-bottom-style:solid; clear:both">
<span style="color:rgb(51,102,153)"><span style="line-height:36px; font-size:22px">&nbsp;1. 引子</span></span></p>
</h2>
</div>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;try…catch…finally恐怕是大家再熟悉不过的语句了，而且感觉用起来也是很简单，逻辑上似乎也是很容易理解。不过，我亲自体验的“教训”告诉我，这个东西可不是想象中的那么简单、听话。不信？那你看看下面的代码，“猜猜”它执行后的结果会是什么？不要往后看答案、也不许执行代码看真正答案哦。如果你的答案是正确，那么这篇文章你就不用浪费时间看啦。</span><br>
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span>&lt;span&nbsp;style=</span><span class="string">"background-color:&nbsp;rgb(255,&nbsp;255,&nbsp;255);"</span><span>&gt;</span><span class="keyword">package</span><span>&nbsp;Test;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;TestException()&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;testEx()&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;ret&nbsp;=&nbsp;</span><span class="keyword">true</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;=&nbsp;testEx1();&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx,&nbsp;catch&nbsp;exception"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;=&nbsp;<span class="keyword">false</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;e;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx,&nbsp;finally;&nbsp;return&nbsp;value="</span><span>&nbsp;+&nbsp;ret);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;ret;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;testEx1()&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;ret&nbsp;=&nbsp;</span><span class="keyword">true</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;=&nbsp;testEx2();&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(!ret)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;</span><span class="keyword">false</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx1,&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;try"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;ret;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx1,&nbsp;catch&nbsp;exception"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;=&nbsp;<span class="keyword">false</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;e;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx1,&nbsp;finally;&nbsp;return&nbsp;value="</span><span>&nbsp;+&nbsp;ret);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;ret;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;testEx2()&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;ret&nbsp;=&nbsp;</span><span class="keyword">true</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;b&nbsp;=&nbsp;</span><span class="number">12</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;c;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">2</span><span>;&nbsp;i&nbsp;&gt;=&nbsp;-</span><span class="number">2</span><span>;&nbsp;i--)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;b&nbsp;/&nbsp;i;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"i="</span><span>&nbsp;+&nbsp;i);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;</span><span class="keyword">true</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx2,&nbsp;catch&nbsp;exception"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;=&nbsp;<span class="keyword">false</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;e;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"testEx2,&nbsp;finally;&nbsp;return&nbsp;value="</span><span>&nbsp;+&nbsp;ret);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;ret;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestException&nbsp;testException1&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;TestException();&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testException1.testEx();&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span>&lt;/span&gt;&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_1_5031439" name="code" class="java" style="display: none;">&lt;span style="background-color: rgb(255, 255, 255);"&gt;package Test;

public class TestException {
	public TestException() {
	}

	boolean testEx() throws Exception {
		boolean ret = true;
		try {
			ret = testEx1();
		} catch (Exception e) {
			System.out.println("testEx, catch exception");
			ret = false;
			throw e;
		} finally {
			System.out.println("testEx, finally; return value=" + ret);
			return ret;
		}
	}

	boolean testEx1() throws Exception {
		boolean ret = true;
		try {
			ret = testEx2();
			if (!ret) {
				return false;
			}
			System.out.println("testEx1, at the end of try");
			return ret;
		} catch (Exception e) {
			System.out.println("testEx1, catch exception");
			ret = false;
			throw e;
		} finally {
			System.out.println("testEx1, finally; return value=" + ret);
			return ret;
		}
	}

	boolean testEx2() throws Exception {
		boolean ret = true;
		try {
			int b = 12;
			int c;
			for (int i = 2; i &gt;= -2; i--) {
				c = b / i;
				System.out.println("i=" + i);
			}
			return true;
		} catch (Exception e) {
			System.out.println("testEx2, catch exception");
			ret = false;
			throw e;
		} finally {
			System.out.println("testEx2, finally; return value=" + ret);
			return ret;
		}
	}

	public static void main(String[] args) {
		TestException testException1 = new TestException();
		try {
			testException1.testEx();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
&lt;/span&gt;</pre><span style="background-color:rgb(255,255,255)"><br>
</span>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">你的答案是什么？是下面的答案吗？</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"><span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px"></span><span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">i=2</span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">i=1</span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">testEx2, catch exception</span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">testEx2, finally; return value=false</span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">testEx1, catch exception</span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px"><span style="color:#ff0000">testEx1, finally; return value=false</span></span><br style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">testEx, catch exception</span><br style="font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(255,0,0); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">testEx, finally; return value=false</span><span style="font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px"><span style="color:#ff0000"></span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">如果你的答案真的如上面所说，那么你错啦。^_^，那就建议你仔细看一看这篇文章或者拿上面的代码按各种不同的情况修改、执行、测试，你会发现有很多事情不是原来想象中的那么简单的。现在公布正确答案：</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">i=2<br>
i=1<br>
testEx2, catch exception<br>
testEx2, finally; return value=false<br>
testEx1, finally; return value=false<br>
testEx, finally; return value=false</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
注意说明：</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
finally语句块不应该出现 应该出现return。上面的return ret最好是其他语句来处理相关逻辑。</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<div>
<h2 style="margin:0px; padding:0px; color:rgb(51,51,51); font-family:Arial; line-height:26px; text-align:left"><a name="t1"></a>
<p class="headline-1 bk-sidecatalog-title" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:6px; border-bottom-color:rgb(222,223,225); border-bottom-width:1px; border-bottom-style:solid; clear:both">
<span style="color:rgb(51,102,153)"><span style="line-height:36px; font-size:22px">&nbsp;2.JAVA异常</span></span></p>
</h2>
</div>
<p><span style="font-family:Arial,宋体; line-height:24px"><span style="color:rgb(0,0,128); font-size:18px; font-family:Simsun; text-indent:28px"><strong>&nbsp; &nbsp;</strong></span><span style="font-family:Simsun; text-indent:28px"><span style="font-size:14px">异常指不期而至的各种状况，如：文件找不到、网络连接失败、非法参数等。异常是一个事件，它发生在程序运行期间，干扰了正常的指令流程。Java通
 过API中Throwable类的众多子类描述各种不同的异常。因而，Java异常都是对象，是Throwable子类的实例，描述了出现在一段编码中的 错误条件。当条件生成时，错误将引发异常。</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">&nbsp; &nbsp; &nbsp; </span><span style="font-size:14px">Java异常类层次结构图：</span></p>
<br>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/1354020417_5176.jpg" alt=""></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="font-family:Arial,宋体; font-size:18px; line-height:24px">图1&nbsp;Java异常类层次结构图</span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-size:14px; line-height:14px">
</p>
<p style="font-family:Arial,宋体; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-size:14px; line-height:24px">
<span style="background-color:rgb(255,255,255)">&nbsp; &nbsp; </span></p>
<span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 在 Java 中，所有的异常都有一个共同的祖先 Throwable（可抛出）。Throwable 指定代码中可用异常传播机制通过 Java 应用程序传输的任何问题的共性。<br>
&nbsp; &nbsp; &nbsp; &nbsp;<strong><span style="color:#3333ff">Throwable：</span></strong> 有两个重要的子类：Exception（异常）和 Error（错误），二者都是 Java 异常处理的重要子类，各自都包含大量子类。<br>
</span>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;<strong><span style="color:#3333ff">Error（错误）:</span></strong>是程序无法处理的错误，表示运行应用程序中较严重问题。大多数错误与代码编写者执行的操作无关，而表示代码运行时 JVM（Java 虚拟机）出现的问题。例如，<span style="font-family:Arial,宋体; font-size:14px; line-height:24px">Java虚拟机运行错误（Virtual
 MachineError），</span>当 JVM 不再有继续执行操作所需的内存资源时，将出现 OutOfMemoryError。这些异常发生时，Java虚拟机（JVM）一般会选择线程终止。</span></p>
<p><span style="font-size:14px"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">。这些错误表示故障发生于虚拟机自身、或者发生在虚拟机试图执行应用时，如Java虚拟机运行错误（Virtual MachineError）、类定义错误（NoClassDefFoundError）等。这些错误是不可查的，因为它们在应用程序的控制和处理能力之 外，而且绝大多数是程序运行时不允许出现的状况。对于设计合理的应用程序来说，即使确实发生了错误，本质上也不应该试图去处理它所引起的异常状况。在
 Java中，错误通过Error的子类描述。</span><br>
</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;<span style="font-size:14px"><span style="color:#3333ff"><strong>Exception（异常）:</strong></span></span><span style="font-size:14px"><span style="font-size:14px">是程序本身可以处理的异常</span>。</span></span></p>
<span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;Exception 类有一个重要的子类 RuntimeException。RuntimeException 类及其子类表示“JVM 常用操作”引发的错误。例如，若试图使用空值对象引用、除数为零或数组越界，则分别引发运行时异常（NullPointerException、ArithmeticException）和 ArrayIndexOutOfBoundException。</span>
<p style="font-family:Arial,宋体; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:宋体"><span style="font-size:14px">&nbsp; &nbsp;</span><span style="font-size:14px"><span style="color:#ff6600">注意：异常和错误的区别：<span style="color:rgb(255,102,0); font-family:宋体; font-size:14px; line-height:24px">异常能被</span><span style="font-size:14px">程序本身可以处理，<span style="font-size:14px">错误是无法处理。</span></span></span></span></span></span></p>
<p style="font-family:Arial,宋体; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:宋体"><span style="font-size:14px"><span style="font-size:14px"><span style="font-size:14px"><span style="color:#ff6600">&nbsp; &nbsp;</span><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">通常，Java的异常(包括Exception和Error)分为<span style="color:#3333ff"><strong>可查的异常（checked
 exceptions）和不可查的异常（unchecked exceptions）</strong></span>。</span><br style="font-family:Arial,宋体; font-size:14px; line-height:24px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; &nbsp; </span>
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:#3333ff">可查异常（编译器要求必须处置的异常）：</span></span><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">正确的程序在运行中，很容易出现的、情理可容的异常状况</span><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">。</span><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">可查异常虽然是异常状况，但在一定程度上它的发生是可以预计的，而且一旦发生这种异常</span><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">状况，就必须采取某种方式进行处理。</span></span></span></span></span></span></p>
<p style="font-family:Arial,宋体; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:宋体"><span style="font-size:14px"><span style="font-size:14px"><span style="font-size:14px"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; &nbsp; 除了RuntimeException及其子类以外，其他的Exception类及其子类都属于可查异常。这种异常的特点是Java编译器会检查它，也就是说，当程序中可能出现这类异常，要么用try-catch语句捕获它，要么用throws子句声明抛出它，否则编译不会通过。</span></span></span></span></span></span></p>
<p style="font-family:Arial,宋体; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:宋体"><span style="font-size:14px; font-family:Arial,宋体; line-height:24px">&nbsp; &nbsp; &nbsp;</span><span style="font-size:14px; font-family:Arial,宋体; line-height:24px"><span style="color:#3333ff">不可查异常(编译器不要求强制处置的异常):</span>包括运行时异常（RuntimeException<span style="font-family:Arial,宋体; font-size:14px; line-height:24px">与其子类</span>）和错误（Error）。</span></span></span></p>
<p style="border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-size:14px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体"><span style="font-size:14px">&nbsp; &nbsp; &nbsp;Exception 这种异常分两大类<span style="color:#3333ff">运行时异常和非运行时异常(编译异常)</span>。程序中应当尽可能去处理这些异常。</span></span></span></p>
<p style="border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-size:14px; line-height:24px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体">&nbsp; &nbsp; &nbsp; &nbsp;<strong><span style="color:#3333ff">运行时异常：</span></strong>都是RuntimeException类及其子类异常，如NullPointerException(<span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px; background-color:rgb(248,248,248)">空指针异常)</span>、IndexOutOfBoundsException(<span style="font-family:Arial,宋体; font-size:14px; line-height:24px">下标越界异常)</span>等，<span style="color:#ff0000">这些异常是不检查异常</span>，程序中可以选择捕获处理，也可以不处理。这些异常一般是由程序逻辑错误引起的，程序应该从逻辑角度尽可能避免这类异常的发生。</span></span></p>
<p style="border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="font-family:Arial,宋体"><span style="background-color:rgb(255,255,255)"><span style="font-size:14px">&nbsp; &nbsp;</span><span style="font-size:14px"> &nbsp;&nbsp;<span style="font-family:宋体; line-height:28px; text-indent:28px">运行时异常的特点是Java编译器不会检查它，也就是说，当程序中可能出现这类异常，即使没有用try-catch语句捕获它，也没有用throws子句声明抛出它，也会编译通过。</span></span></span><br>
</span><span style="font-size:14px; background-color:rgb(255,255,255); font-family:Arial,宋体">&nbsp; &nbsp; &nbsp; &nbsp;<strong><span style="color:#3333ff"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">非运行时异常</span>&nbsp;（<span style="font-family:Arial,宋体; font-size:14px; line-height:24px">编译异常</span>）：</span></strong>是RuntimeException以外的异常，类型上都属于Exception类及其子类。从程序语法角度讲是必须进行处理的异常，如果不处理，程序就不能编译通过。如IOException、SQLException等以及用户自定义的Exception异常，一般情况下不自定义<span style="color:#ff0000">检查异常</span>。</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<strong><span style="text-align:center; color:rgb(51,51,51); font-family:宋体; line-height:28px; text-indent:28px">&nbsp; &nbsp;&nbsp;</span></strong></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<div>
<h2 style="margin:0px; padding:0px; color:rgb(51,51,51); font-family:Arial; line-height:26px; text-align:left"><a name="t2"></a>
<p class="headline-1 bk-sidecatalog-title" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:6px; border-bottom-color:rgb(222,223,225); border-bottom-width:1px; border-bottom-style:solid; clear:both">
<span style="color:rgb(51,102,153)"><span style="line-height:36px; font-size:22px">&nbsp;4.处理异常机制</span></span></p>
</h2>
</div>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-size:14px">
<span style="font-family:tahoma,helvetica,arial"><span style="line-height:14px">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></span><span style="font-family:Arial,宋体; line-height:24px">在 Java 应用程序中</span><span style="font-size:14px; font-family:Arial,宋体; line-height:24px">，异常处理机制为：</span><span style="font-family:Arial,宋体; line-height:24px"><span style="color:#ff0000"><span style="font-size:14px">抛出异常，</span><span style="font-size:14px">捕捉异常。</span></span></span></p>
<p><span style="font-size:14px"><span style="color:#3333ff"><strong>&nbsp; &nbsp; &nbsp; &nbsp; 抛出异常</strong>：</span>当一个方法出现错误引发异常时，方法创建异常对象并交付运行时系统，异常对象中包含了异常类型和异常出现时的程序状态等异常信息。运行时系统负责寻找处置异常的代码并执行。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;<strong><span style="color:#3333ff"> 捕获异常</span></strong>：在方法抛出异常之后，运行时系统将转为寻找合适的异常处理器（exception handler）。潜在的异常处理器是异常发生时依次存留在调用栈中的方法的集合。当异常处理器所能处理的异常类型与方法抛出的异常类型相符时，即为合适 的异常处理器。运行时系统从发生异常的方法开始，依次回查调用栈中的方法，直至找到含有合适异常处理器的方法并执行。当运行时系统遍历调用栈而未找到合适
 的异常处理器，则运行时系统终止。同时，意味着Java程序的终止。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 对于运行时异常、错误或可查异常，Java技术所要求的异常处理方式有所不同。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 由于运行时异常的不可查性，为了更合理、更容易地实现应用程序，Java规定，运行时异常将由Java运行时系统自动抛出，允许应用程序忽略运行时异常。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;对于方法运行中可能出现的Error，当运行方法不欲捕捉时，Java允许该方法不做任何抛出声明。因为，大多数Error异常属于永远不能被允许发生的状况，也属于合理的应用程序不该捕捉的异常。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;对于所有的可查异常，Java规定：一个方法必须捕捉，或者声明抛出方法之外。也就是说，当一个方法选择不捕捉可查异常时，它必须声明将抛出异常。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 能够捕捉异常的方法，需要提供相符类型的异常处理器。所捕捉的异常，可能是由于自身语句所引发并抛出的异常，也可能是由某个调用的方法或者Java运行时 系统等抛出的异常。也就是说，<span style="color:#ff0000">一个方法所能捕捉的异常，一定是Java代码在某处所抛出的异常</span>。<span style="color:#ff0000">简单地说，异常总是先被抛出，后被捕捉的。</span></span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#666666">&nbsp;任何Java代码都可以抛出异常，如：自己编写的代码、来自Java开发环境包中代码，或者Java运行时系统。无论是谁，都可以通过Java的throw语句抛出异常。</span></span></p>
<p><span style="font-size:14px"><span style="color:#666666">&nbsp; &nbsp; &nbsp; &nbsp; 从方法中抛出的任何异常都必须使用throws子句。</span></span></p>
<p><span style="font-size:14px"><span style="color:#666666">&nbsp; &nbsp; &nbsp; &nbsp; 捕捉异常通过try-catch语句或者try-catch-finally语句实现。</span></span></p>
<p><span style="font-size:14px"><span style="color:#666666">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;总体来说，Java规定：对于可查异常必须捕捉、或者声明抛出。允许忽略不可查的RuntimeException和Error。</span></span></p>
<h3><a name="t3"></a><span style="background-color:rgb(255,255,255)"><span style="font-size:14px; color:#3333ff"><strong>4.1 捕获异常：try、catch 和 finally</strong></span></span></h3>
<p style="font-size:14px; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-family:Arial,宋体; line-height:24px">
<span style="background-color:rgb(255,255,255)"></span></p>
<h4><a name="t4"></a><span style="font-family:Simsun"><strong><span style="font-size:14px; color:#3333ff">1.try-catch语句</span></strong></span></h4>
<p><span style="font-size:18px">&nbsp; &nbsp; &nbsp;</span><span style="font-size:14px">在Java中，异常通过try-catch语句捕获。其一般语法形式为：</span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;可能会发生异常的程序代码</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Type1&nbsp;id1){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;捕获并处置try抛出的异常类型Type1</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span><span class="keyword">catch</span><span>&nbsp;(Type2&nbsp;id2){&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//捕获并处置try抛出的异常类型Type2</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_2_1694560" name="code" class="java" style="display: none;">try {
    // 可能会发生异常的程序代码
} catch (Type1 id1){
    // 捕获并处置try抛出的异常类型Type1
}
catch (Type2 id2){
     //捕获并处置try抛出的异常类型Type2
}</pre>
<p></p>
<p><span style="font-size:18px">&nbsp; &nbsp; &nbsp; </span><span style="font-size:14px">&nbsp;关键词try后的一对大括号将一块可能发生异常的代码包起来，称为监控区域。Java方法在运行过程中出现异常，则创建异常对象。将异常抛出监控区域之 外，由Java运行时系统试图寻找匹配的catch子句以捕获异常。若有匹配的catch子句，则运行其异常处理代码，try-catch语句结束。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;匹配的原则是：如果抛出的异常对象属于catch子句的异常类，或者属于该异常类的子类，则认为生成的异常对象与catch块捕获的异常类型相匹配。</span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:18px; color:#FF0000">例1</span><span style="font-size:18px; color:#000080">&nbsp; 捕捉throw语句抛出的“除数为0”异常。</span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:18px; color:#000080"></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;a&nbsp;=&nbsp;</span><span class="number">6</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;b&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;</span><span class="comment">//&nbsp;try监控区域</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(b&nbsp;==&nbsp;</span><span class="number">0</span><span>)&nbsp;</span><span class="keyword">throw</span><span>&nbsp;</span><span class="keyword">new</span><span>&nbsp;ArithmeticException();&nbsp;</span><span class="comment">//&nbsp;通过throw语句抛出异常</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"a/b的值是："</span><span>&nbsp;+&nbsp;a&nbsp;/&nbsp;b);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArithmeticException&nbsp;e)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;catch捕捉异常</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序出现异常，变量b不能为0。"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序正常结束。"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_3_582528" name="code" class="java" style="display: none;">public class TestException {
	public static void main(String[] args) {
		int a = 6;
		int b = 0;
		try { // try监控区域
			
			if (b == 0) throw new ArithmeticException(); // 通过throw语句抛出异常
			System.out.println("a/b的值是：" + a / b);
		}
		catch (ArithmeticException e) { // catch捕捉异常
			System.out.println("程序出现异常，变量b不能为0。");
		}
		System.out.println("程序正常结束。");
	}
}</pre>
<p></p>
<p><span style="font-size:14px">运行结果：<span style="color:#999999">程序出现异常，变量b不能为0。</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 程序正常结束。</span></span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 例1&nbsp; 在try监控区域通过if语句进行判断，当“除数为0”的错误条件成立时引发ArithmeticException异常，创建 ArithmeticException异常对象，并由throw语句将异常抛给Java运行时系统，由系统寻找匹配的异常处理器catch并运行相应异 常处理代码，打印输出“程序出现异常，变量b不能为0。”try-catch语句结束，继续程序流程。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 事实上，“除数为0”等ArithmeticException，是RuntimException的子类。而运行时异常将由运行时系统自动抛出，不需要使用throw语句。</span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:14px"><span style="color:rgb(255,0,0)">例2&nbsp;</span><span style="color:rgb(0,0,128)">&nbsp;捕捉运行时系统自动抛出“除数为0”引发的ArithmeticException异常。</span></span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:18px; color:#800000"></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_4" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;a&nbsp;=&nbsp;</span><span class="number">6</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;b&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"a/b的值是："</span><span>&nbsp;+&nbsp;a&nbsp;/&nbsp;b);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArithmeticException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序出现异常，变量b不能为0。"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序正常结束。"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_4_6264129" name="code" class="java" style="display: none;">	public static void main(String[] args) {
		int a = 6;
		int b = 0;
		try {
			System.out.println("a/b的值是：" + a / b);
		} catch (ArithmeticException e) {
			System.out.println("程序出现异常，变量b不能为0。");
		}
		System.out.println("程序正常结束。");
	}
}</pre>
<p><span style="font-size:14px">运行结果：<span style="color:#999999">程序出现异常，变量b不能为0。</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 程序正常结束。</span></span></p>
<p><span style="font-size:14px">例2&nbsp; 中的语句：</span></p>
<p><span style="font-size:14px">System.out.println("a/b的值是：" + a/b);</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; 在运行中出现“除数为0”错误，引发ArithmeticException异常。运行时系统创建异常对象并抛出监控区域，转而匹配合适的异常处理器catch，并执行相应的异常处理代码。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; 由于检查运行时异常的代价远大于捕捉异常所带来的益处，运行时异常不可查。Java编译器允许忽略运行时异常，一个方法可以既不捕捉，也不声明抛出运行时异常。</span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:14px"><span style="color:rgb(255,0,0)">例3&nbsp;</span><span style="color:rgb(0,0,128)">&nbsp;不捕捉、也不声明抛出运行时异常。</span></span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_5" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;a,&nbsp;b;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;<span class="number">6</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;=&nbsp;<span class="number">0</span><span>;&nbsp;</span><span class="comment">//&nbsp;除数b&nbsp;的值为0</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(a&nbsp;/&nbsp;b);&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_5_4595689" name="code" class="java" style="display: none;">public class TestException {
	public static void main(String[] args) {
		int a, b;
		a = 6;
		b = 0; // 除数b 的值为0
		System.out.println(a / b);
	}
}</pre>
<p></p>
<p><span style="font-size:18px">运行结果：</span></p>
<p style="color:rgb(69,69,69)">Exception in thread "main" java.lang.ArithmeticException: / by zero<br>
<span style="white-space:pre"></span>at Test.TestException.main(TestException.java:8)<br>
</p>
<p style="color:rgb(69,69,69)"><span style="font-size:14px"><span style="color:rgb(255,0,0)">例4</span><span style="color:rgb(0,0,128)">&nbsp; 程序可能存在除数为0异常和数组下标越界异常。</span></span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_6" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_6" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=6&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>[]&nbsp;intArray&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;</span><span class="keyword">int</span><span>[</span><span class="number">3</span><span>];&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;i&nbsp;&lt;=&nbsp;intArray.length;&nbsp;i++)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;intArray[i]&nbsp;=&nbsp;i;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"intArray["</span><span>&nbsp;+&nbsp;i&nbsp;+&nbsp;</span><span class="string">"]&nbsp;=&nbsp;"</span><span>&nbsp;+&nbsp;intArray[i]);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"intArray["</span><span>&nbsp;+&nbsp;i&nbsp;+&nbsp;</span><span class="string">"]模&nbsp;"</span><span>&nbsp;+&nbsp;(i&nbsp;-&nbsp;</span><span class="number">2</span><span>)&nbsp;+&nbsp;</span><span class="string">"的值:&nbsp;&nbsp;"</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+&nbsp;intArray[i]&nbsp;%&nbsp;(i&nbsp;-&nbsp;<span class="number">2</span><span>));&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArrayIndexOutOfBoundsException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"intArray数组下标越界异常。"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArithmeticException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"除数为0异常。"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序正常结束。"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_6_5435504" name="code" class="java" style="display: none;">public class TestException {
	public static void main(String[] args) {
		int[] intArray = new int[3];
		try {
			for (int i = 0; i &lt;= intArray.length; i++) {
				intArray[i] = i;
				System.out.println("intArray[" + i + "] = " + intArray[i]);
				System.out.println("intArray[" + i + "]模 " + (i - 2) + "的值:  "
						+ intArray[i] % (i - 2));
			}
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println("intArray数组下标越界异常。");
		} catch (ArithmeticException e) {
			System.out.println("除数为0异常。");
		}
		System.out.println("程序正常结束。");
	}
}</pre>
<p></p>
<p><span style="font-size:14px">运行结果：</span></p>
<p><span style="color:#999999"><span style="font-size:14px">intArray[0] = 0</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">intArray[0]模 -2的值:&nbsp; 0</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">intArray[1] = 1</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">intArray[1]模 -1的值:&nbsp; 0</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">intArray[2] = 2</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">除数为0异常。</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">程序正常结束。</span></span></p>
<p><span style="font-size:14px"><span style="color:rgb(0,0,128)">&nbsp; &nbsp; &nbsp; </span>例4&nbsp; 程序可能会出现除数为0异常，还可能会出现数组下标越界异常。程序运行过程中ArithmeticException异常类型是先行匹配的，因此执行相匹配的catch语句：</span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_7" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_7" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=7&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">catch</span><span>&nbsp;(ArithmeticException&nbsp;e){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"除数为0异常。"</span><span>);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_7_5784952" name="code" class="java" style="display: none;">catch (ArithmeticException e){
      System.out.println("除数为0异常。");
 }</pre>
<p></p>
<p><span style="color:rgb(0,0,128); font-size:18px">&nbsp; &nbsp; &nbsp; </span><span style="font-size:14px"><span style="color:rgb(0,0,128)">&nbsp;</span>需要注意的是，<span style="color:#ff0000">一旦某个catch捕获到匹配的异常类型，将进入异常处理代码。一经处理结束，就意味着整个try-catch语句结束。其他的catch子句不再有匹配和捕获异常类型的机会。</span></span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; Java通过异常类描述异常类型，异常类的层次结构如图1所示。对于有多个catch子句的异常程序而言，应该尽量将捕获底层异常类的catch子 句放在前面，同时尽量将捕获相对高层的异常类的catch子句放在后面。否则，捕获底层异常类的catch子句将可能会被屏蔽。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp; RuntimeException异常类包括运行时各种常见的异常，ArithmeticException类和ArrayIndexOutOfBoundsException类都是它的子类。因此，RuntimeException异常类的catch子句应该放在 最后面，否则可能会屏蔽其后的特定异常处理或引起编译错误。</span></p>
<h4><a name="t5"></a><span style="font-family:Simsun"><strong><span style="font-size:18px; color:#3333ff">2. try－catch-finally语句</span></strong></span></h4>
<p><span style="font-size:18px">&nbsp; &nbsp; &nbsp;</span><span style="font-size:14px"> try-catch语句还可以包括第三部分，就是finally子句。它表示无论是否出现异常，都应当执行的内容。try-catch-finally语句的一般语法形式为：</span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:18px; color:#800000"></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_8" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_8" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=8&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;可能会发生异常的程序代码</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Type1&nbsp;id1)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;捕获并处理try抛出的异常类型Type1</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Type2&nbsp;id2)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;捕获并处理try抛出的异常类型Type2</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;无论是否发生异常，都将执行的语句块</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_8_38094" name="code" class="java" style="display: none;">                try {
			// 可能会发生异常的程序代码
		} catch (Type1 id1) {
			// 捕获并处理try抛出的异常类型Type1
		} catch (Type2 id2) {
			// 捕获并处理try抛出的异常类型Type2
		} finally {
			// 无论是否发生异常，都将执行的语句块
		}</pre><br>
<p style="color:rgb(69,69,69)"><span style="font-size:18px; color:#800000"></span></p>
<p style="color:rgb(69,69,69)"><span style="font-size:14px"><span style="color:rgb(255,0,0)">例5&nbsp;</span><span style="color:rgb(0,0,128)">&nbsp;带finally子句的异常处理程序。</span></span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_9" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_9" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=9&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String&nbsp;args[])&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;greetings[]&nbsp;=&nbsp;{&nbsp;<span class="string">"&nbsp;Hello&nbsp;world&nbsp;!"</span><span>,&nbsp;</span><span class="string">"&nbsp;Hello&nbsp;World&nbsp;!!&nbsp;"</span><span>,&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="string">"&nbsp;HELLO&nbsp;WORLD&nbsp;!!!"</span><span>&nbsp;};&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">while</span><span>&nbsp;(i&nbsp;&lt;&nbsp;</span><span class="number">4</span><span>)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;特别注意循环控制变量i的设计，避免造成无限循环</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(greetings[i++]);&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArrayIndexOutOfBoundsException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"数组下标越界异常"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"--------------------------"</span><span>);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_9_4814623" name="code" class="java" style="display: none;">public class TestException {
	public static void main(String args[]) {
		int i = 0;
		String greetings[] = { " Hello world !", " Hello World !! ",
				" HELLO WORLD !!!" };
		while (i &lt; 4) {
			try {
				// 特别注意循环控制变量i的设计，避免造成无限循环
				System.out.println(greetings[i++]);
			} catch (ArrayIndexOutOfBoundsException e) {
				System.out.println("数组下标越界异常");
			} finally {
				System.out.println("--------------------------");
			}
		}
	}
}</pre><br>
<p></p>
<p><span style="font-size:14px">运行结果：</span></p>
<p><span style="color:#999999"><span style="font-size:14px">Hello world !</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">--------------------------</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">Hello World !!</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">--------------------------</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">HELLO WORLD !!!</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">--------------------------</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">数组下标越界异常</span></span></p>
<p><span style="color:#999999"><span style="font-size:14px">--------------------------</span></span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; &nbsp;在例5中，请特别注意try子句中语句块的设计，如果设计为如下，将会出现死循环。如果设计为：</span></p>
<p style="color:rgb(69,69,69)"></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_10" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_10" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=10&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println&nbsp;(greetings[i]);&nbsp;i++;&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_10_5479715" name="code" class="java" style="display: none;">try {
      System.out.println (greetings[i]); i++;
}</pre>
<p><br>
</p>
<p><span style="font-size:18px">小结：</span></p>
<p style="font-size:14px; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-family:Arial,宋体; line-height:24px">
<span style="color:rgb(69,69,69)"><strong>try 块：</strong>用于捕获异常。其后可接零个或多个catch块，如果没有catch块，则必须跟一个finally块。<br>
<strong>catch 块：</strong>用于处理try捕获到的异常。<br>
<strong>finally 块：</strong>无论是否捕获或处理异常，finally块里的语句都会被执行。</span><span style="color:#ff0000">当在try块或catch块中遇到return语句时，finally语句块将在方法返回之前被执行。在以下4种特殊情况下，finally块不会被执行：</span><br>
1）在finally语句块中发生了异常。<br>
2）在前面的代码中用了System.exit()退出程序。<br>
3）程序所在的线程死亡。<br>
4）关闭CPU。</p>
<p style="font-size:14px; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-family:Arial,宋体; line-height:24px">
<span style="color:#ff0000"><br>
</span></p>
<p style="border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-family:Arial,宋体; line-height:24px">
</p>
<h4><a name="t6"></a><span style="font-size:18px; color:rgb(51,51,255)"><strong>3. try-catch-finally 规则(</strong><a target="_blank" href="http://book.51cto.com/art/201009/227791.htm" title="16.2.5  异常处理语句的语法规则" style="color:rgb(51,51,51); text-decoration:none; font-family:宋体; line-height:22px"><strong>异常处理语句的语法规则</strong></a><strong>）：</strong></span></h4>
<p style="font-size:14px; margin-top:0px; margin-bottom:12px; padding-top:0px; padding-bottom:0px; border:0px; font-family:Arial,宋体; line-height:24px">
<span style="color:#454545">1) &nbsp;必须在 try 之后添加 catch 或 finally 块。try 块后可同时接 catch 和 finally 块，但至少有一个块。</span><br>
<span style="color:#454545">2) 必须遵循块顺序：若代码同时使用 catch 和 finally 块，则必须将 catch 块放在 try 块之后。</span><br>
<span style="color:#454545">3) catch 块与相应的异常类的类型相关。</span><br>
<span style="color:#454545">4) 一个 try 块可能有多个 catch 块。若如此，则执行第一个匹配块。即Java虚拟机会把实际抛出的异常对象依次和各个catch代码块声明的异常类型匹配，如果异常对象为某个异常类型或其子类的实例，就执行这个catch代码块，不会再执行其他的 catch代码块</span><br>
<span style="color:#454545">5) 可嵌套 try-catch-finally 结构。</span><br>
<span style="color:#454545">6) 在 try-catch-finally 结构中，可重新抛出异常。</span><br>
<span style="color:#454545">7) 除了下列情况，总将执行 finally 做为结束：</span><span style="color:#ff6600">JVM 过早终止（调用 System.exit(int)）；在 finally 块中抛出一个未处理的异常；计算机断电、失火、或遭遇病毒攻击。</span></p>
<h4><a name="t7"></a><span style="font-family:arial,helvetica,sans-serif,verdana,宋体; line-height:18px"><strong><span style="font-size:14px; color:#3333ff">4. try、catch、finally语句块的执行顺序:</span></strong></span></h4>
<p style="color:rgb(69,69,69); font-size:14px; margin-top:0px; margin-bottom:12px; padding-top:0px; padding-bottom:0px; border:0px; font-family:Arial,宋体; line-height:24px">
</p>
<p style="color:rgb(51,51,51); font-size:14px; margin-top:0px; margin-bottom:16px; padding-top:0px; padding-bottom:0px; line-height:18px; text-align:justify; font-family:arial,helvetica,sans-serif,verdana,宋体">
1)当try没有捕获到异常时：try语句块中的语句逐一被执行，程序将跳过catch语句块，执行finally语句块和其后的语句；</p>
<p style="color:rgb(51,51,51); font-size:14px; margin-top:0px; margin-bottom:16px; padding-top:0px; padding-bottom:0px; line-height:18px; text-align:justify; font-family:arial,helvetica,sans-serif,verdana,宋体">
2)当try捕获到异常，catch语句块里没有处理此异常的情况：当try语句块里的某条语句出现异常时，而没有处理此异常的catch语句块时，此异常将会抛给JVM处理，finally语句块里的语句还是会被执行，但finally语句块后的语句不会被执行；</p>
<p style="color:rgb(51,51,51); font-size:14px; margin-top:0px; margin-bottom:16px; padding-top:0px; padding-bottom:0px; line-height:18px; text-align:justify; font-family:arial,helvetica,sans-serif,verdana,宋体">
3)当try捕获到异常，catch语句块里有处理此异常的情况：在try语句块中是按照顺序来执行的，当执行到某一条语句出现异常时，程序将跳到catch语句块，并与catch语句块逐一匹配，找到与之对应的处理程序，其他的catch语句块将不会被执行，而try语句块中，出现异常之后的语句也不会被执行，catch语句块执行完后，执行finally语句块里的语句，最后执行finally语句块后的语句；</p>
<span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; line-height:18px"><span style="font-weight:bold"><span style="font-size:18px"><span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; font-size:14px; line-height:18px; text-align:justify">&nbsp;</span><span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; font-size:14px; line-height:18px"><span style="font-size:18px">图示try、catch、finally语句块的执行：</span></span></span></span></span>
<p style="margin-top:0px; margin-bottom:12px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-size:14px; border:0px; font-family:Arial,宋体; line-height:24px">
<span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; line-height:18px; text-align:justify"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/1354022670_6403.jpg" alt=""></span></p>
<p style="margin-top:0px; margin-bottom:12px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-size:14px; border:0px; font-family:Arial,宋体; line-height:24px">
<span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; line-height:18px; text-align:justify">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 图2 &nbsp;<span style="color:rgb(51,51,51); font-family:arial,helvetica,sans-serif,verdana,宋体; line-height:18px"><span style="font-size:18px">图示try、catch、finally语句块的执行</span></span><br style="font-family:Arial,宋体; line-height:24px">
<br>
</span></p>
<h3><a name="t8"></a><span style="background-color:rgb(255,255,255)"><span style="font-size:18px; color:#3333ff"><strong>4.2 抛出异常</strong></span></span></h3>
<div>
<p><span style="font-size:14px"><span style="color:rgb(102,102,102)">&nbsp; &nbsp; &nbsp; 任何Java代码都可以抛出异常，如：自己编写的代码、来自Java开发环境包中代码，或者Java运行时系统。无论是谁，都可以通过Java的throw语句抛出异常。</span></span><span style="color:rgb(102,102,102); font-size:14px">从方法中抛出的任何异常都必须使用throws子句。</span></p>
<h4><a name="t9"></a><span style="font-family:宋体; line-height:24px"><span style="text-align:center; font-family:宋体; line-height:28px; text-indent:28px; background-color:rgb(248,248,248)"><span style="color:rgb(51,51,255)"><span style="font-size:14px">1. throws抛出异常</span></span></span></span></h4>
</div>
<p style="font-size:14px; border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; font-family:Arial,宋体; line-height:24px">
<span style="font-family:宋体; color:rgb(69,69,69)">&nbsp; &nbsp;如果一个方法可能会出现异常，但没有能力处理这种异常，可以在方法声明处用throws子句来声明抛出异常。例如汽车在运行时可能会出现故障，汽车本身没办法处理这个故障，那就让开车的人来处理。</span></p>
<p style="color:rgb(69,69,69); border:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:12px; line-height:24px">
<span style="font-family:Arial,宋体"><span style="font-size:14px">&nbsp; &nbsp; &nbsp;</span></span><span style="font-family:Simsun"><span style="font-size:14px">throws语句用在方法定义时声明该方法要抛出的异常类型，如果抛出的是Exception异常类型，则该方法被声明为抛出所有的异常。<span style="font-family:Simsun; font-size:14px">多个异常可使用逗号分割。</span>throws语句的语法格式为：</span></span><br style="font-family:Simsun; font-size:12px">
</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_11" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_11" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=11&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span>methodname&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception1,Exception2,..,ExceptionN&nbsp;&nbsp;</span></span></li><li class=""><span>{&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_11_5098814" name="code" class="java" style="font-family: Arial, 宋体; font-size: 14px; display: none;">methodname throws Exception1,Exception2,..,ExceptionN
{
}</pre>
<p><span style="font-family:Simsun; font-size:12px">&nbsp;&nbsp;&nbsp; </span><span style="font-family:Simsun"><span style="font-size:14px">方法名后的throws Exception1,Exception2,...,ExceptionN 为声明要抛出的异常列表。当方法抛出<span style="color:rgb(69,69,69); font-family:Simsun; line-height:24px">异常</span>列表的异常时，方法将不对这些类型及其子类类型的<span style="color:rgb(69,69,69); font-family:Simsun; line-height:24px">异常</span>作处理，而抛向调用该方法的方法，由他去处理。</span></span><span style="font-size:14px; font-family:Simsun">例如：</span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"></span></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_12" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_12" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=12&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.lang.Exception;&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;pop()&nbsp;</span><span class="keyword">throws</span><span>&nbsp;NegativeArraySizeException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;定义方法并抛出NegativeArraySizeException异常</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>[]&nbsp;arr&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;</span><span class="keyword">int</span><span>[-</span><span class="number">3</span><span>];&nbsp;</span><span class="comment">//&nbsp;创建数组</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;主方法</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;</span><span class="comment">//&nbsp;try语句处理异常信息</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pop();&nbsp;<span class="comment">//&nbsp;调用pop()方法</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(NegativeArraySizeException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"pop()方法抛出的异常"</span><span>);</span><span class="comment">//&nbsp;输出异常信息</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_12_5763905" name="code" class="java" style="display: none;">import java.lang.Exception;
public class TestException {
	static void pop() throws NegativeArraySizeException {
		// 定义方法并抛出NegativeArraySizeException异常
		int[] arr = new int[-3]; // 创建数组
	}

	public static void main(String[] args) { // 主方法
		try { // try语句处理异常信息
			pop(); // 调用pop()方法
		} catch (NegativeArraySizeException e) {
			System.out.println("pop()方法抛出的异常");// 输出异常信息
		}
	}

}</pre>
<p></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"><span style="font-family:Simsun; font-size:14px">&nbsp; &nbsp; 使用throws关键字将异常抛给调用者后，如果<span style="font-family:Simsun; font-size:14px">调用者</span>不想处理该异常，可以继续向上抛出，但最终要有能够处理该异常的<span style="font-family:Simsun; font-size:14px">调用者</span>。</span></span></span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px">&nbsp; &nbsp; pop方法没有处理异常NegativeArraySizeException，而是由main函数来处理。<br style="font-family:Simsun; font-size:14px">
<br style="font-family:Simsun; font-size:14px">
<span style="font-family:Simsun; font-size:14px">&nbsp; &nbsp;<span style="color:#ff0000"> </span>
<span style="font-size:14px"><strong><span style="color:#3333ff">Throws抛出异常的规则：</span></strong></span><span style="color:#ff0000"></span></span></span></span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"><span style="font-family:Simsun; font-size:14px"><span style="color:#ff0000">&nbsp; &nbsp; 1) 如果是<span style="font-size:14px">不可查异常（unchecked exception），即</span>Error、RuntimeException或它们的子类，那么可以不使用throws关键字来声明要抛出的异常，编译仍能顺利通过，但在运行时会被系统抛出。</span></span></span></span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"><span style="font-family:Simsun; font-size:14px"><span style="color:#ff0000">&nbsp; &nbsp; 2）<span style="font-size:14px">必须声明方法可抛出的任何可查异常（checked exception）。即<span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px; background-color:rgb(255,255,255)">如果一个方法可能出现受可查异常，要么用try-catch语句捕获，要么用throws子句声明将它抛出，否则会导致编译错误</span></span></span></span></span></span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"><span style="color:#ff0000">&nbsp; &nbsp; 3)仅当抛出了异常，该方法的调用者才必须处理或者重新抛出该异常</span>。当方法的调用者无力处理该异常的时候，应该继续抛出，而不是囫囵吞枣。</span></span></p>
<p><span style="font-family:Simsun"><span style="font-size:14px"></span></span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; 4）<span style="font-size:14px">调用方法</span><span style="color:rgb(255,0,0); font-family:Simsun; font-size:14px"><span style="color:rgb(255,0,0); font-family:Simsun; font-size:14px"></span></span>必须遵循任何可查异常的处理和声明规则。若覆盖一个方法，则不能声明与覆盖方法不同的异常。声明的任何异常必须是被覆盖方法所声明异常的同类或子类。</span></p>
<p><span style="font-size:14px">&nbsp; &nbsp; 例如：</span></p>
<p><span style="font-size:14px"></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_13" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_13" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=13&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">void</span><span>&nbsp;method1()&nbsp;</span><span class="keyword">throws</span><span>&nbsp;IOException{}&nbsp;&nbsp;</span><span class="comment">//合法&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span><span class="comment">//编译错误，必须捕获或声明抛出IOException&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">void</span><span>&nbsp;method2(){&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;</span></li><li class=""><span><span class="comment">//合法，声明抛出IOException&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">void</span><span>&nbsp;method3()</span><span class="keyword">throws</span><span>&nbsp;IOException&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span><span class="comment">//合法，声明抛出Exception，IOException是Exception的子类&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">void</span><span>&nbsp;method4()</span><span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;</span></li><li class=""><span><span class="comment">//合法，捕获IOException&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">void</span><span>&nbsp;method5(){&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;<span class="keyword">try</span><span>{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;}<span class="keyword">catch</span><span>(IOException&nbsp;e){…}&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span><span class="comment">//编译错误，必须捕获或声明抛出Exception&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">void</span><span>&nbsp;method6(){&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;<span class="keyword">try</span><span>{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;}<span class="keyword">catch</span><span>(IOException&nbsp;e){</span><span class="keyword">throw</span><span>&nbsp;</span><span class="keyword">new</span><span>&nbsp;Exception();}&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;</span></li><li class=""><span><span class="comment">//合法，声明抛出Exception&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">void</span><span>&nbsp;method7()</span><span class="keyword">throws</span><span>&nbsp;Exception{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;<span class="keyword">try</span><span>{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;method1();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;}<span class="keyword">catch</span><span>(IOException&nbsp;e){</span><span class="keyword">throw</span><span>&nbsp;</span><span class="keyword">new</span><span>&nbsp;Exception();}&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_13_6603720" name="code" class="java" style="display: none;">void method1() throws IOException{}  //合法  
 
//编译错误，必须捕获或声明抛出IOException  
void method2(){  
  method1();  
}  
 
//合法，声明抛出IOException  
void method3()throws IOException {  
  method1();  
}  
 
//合法，声明抛出Exception，IOException是Exception的子类  
void method4()throws Exception {  
  method1();  
}  
 
//合法，捕获IOException  
void method5(){  
 try{  
    method1();  
 }catch(IOException e){…}  
}  
 
//编译错误，必须捕获或声明抛出Exception  
void method6(){  
  try{  
    method1();  
  }catch(IOException e){throw new Exception();}  
}  
 
//合法，声明抛出Exception  
void method7()throws Exception{  
 try{  
  method1();  
 }catch(IOException e){throw new Exception();}  
} </pre>&nbsp; &nbsp; <strong><span style="color:#3333ff">&nbsp;判断一个方法可能会出现异常的依据如下：</span></strong><br>
&nbsp; &nbsp; &nbsp;1）方法中有throw语句。例如，以上method7()方法的catch代码块有throw语句。<br>
&nbsp; &nbsp; &nbsp;2）调用了其他方法，其他方法用throws子句声明抛出某种异常。例如，method3()方法调用了method1()方法，method1()方法声明抛出IOException，因此，在method3()方法中可能会出现IOException。
<p></p>
<h4><a name="t10"></a><span style="font-family:宋体; line-height:24px"><span style="text-align:center; line-height:28px; text-indent:28px; background-color:rgb(248,248,248)"><span style="color:rgb(51,51,255)"><span style="font-size:14px">2. 使用throw抛出异常</span></span></span></span></h4>
<span style="font-size:14px"><span style="font-family:宋体; line-height:24px">　 &nbsp;throw总是出现在函数体中，<span style="color:rgb(69,69,69); font-family:Arial,宋体; line-height:24px">用来抛出一个Throwable类型的异常</span>。程序会在throw语句后立即终止，它后面的语句执行不到，然后在包含它的所有try块中（可能在上层调用函数中）从里向外寻找含有与其匹配的catch子句的try块。</span><br style="font-family:宋体; line-height:24px">
<span style="line-height:24px"><span style="font-family:宋体">　　</span><span style="font-family:Simsun">我们知道，异常是异常类的实例对象，我们可以创建异常类的实例对象通过throw语句抛出。该语句的语法格式为：</span><br style="font-family:Simsun">
<span style="font-family:Simsun">&nbsp; &nbsp;&nbsp;<span style="color:rgb(69,69,69); font-family:Simsun; line-height:24px">throw new exceptionname;</span></span><br style="font-family:Simsun">
<span style="font-family:Simsun">&nbsp;&nbsp;&nbsp; 例如抛出一个IOException类的异常对象：</span><br style="font-family:Simsun">
<span style="font-family:Simsun">&nbsp; &nbsp; throw new IOException;</span><br style="font-family:Simsun">
<span style="font-family:Simsun">&nbsp;&nbsp;&nbsp; 要注意的是，throw 抛出的只能够是可抛出类Throwable 或者其子类的实例对象。下面的操作是错误的：</span><br style="font-family:Simsun">
<span style="font-family:Simsun">&nbsp; &nbsp; throw new String("exception");</span><br style="font-family:Simsun">
</span></span>
<p><span style="line-height:24px"><span style="font-family:Simsun"><span style="font-size:14px">&nbsp;&nbsp;&nbsp; 这是因为String 不是Throwable 类的子类。</span></span></span></p>
<p><span style="line-height:24px"><span style="font-family:Simsun; font-size:12px">&nbsp; &nbsp; &nbsp;<span style="color:rgb(69,69,69); font-family:Arial,宋体; font-size:14px; line-height:24px">如果抛出了检查异常，则还应该在方法头部声明方法可能抛出的异常类型。该方法的调用者也必须检查处理抛出的异常。</span></span></span></p>
<p><span style="line-height:24px"><span style="font-family:Simsun; font-size:12px"><span style="color:rgb(69,69,69); font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; &nbsp; &nbsp;如果所有方法都层层上抛获取的异常，最终JVM会进行处理，处理也很简单，就是打印异常消息和堆栈信息。如果抛出的是Error或RuntimeException，则该方法的调用者可选择处理该异常。</span></span></span></p>
<p><span style="line-height:24px"><span style="font-family:Simsun; font-size:12px"><span style="color:rgb(69,69,69); font-family:Arial,宋体; font-size:14px; line-height:24px"></span></span></span></p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><a href="https://code.csdn.net/snippets/456083" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a><a href="https://code.csdn.net/snippets/456083/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a><div style="position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 99;"><embed id="ZeroClipboardMovie_14" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="0" height="0" name="ZeroClipboardMovie_14" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=14&amp;width=0&amp;height=0" wmode="transparent"></div></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="keyword">package</span><span>&nbsp;Test;&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">import</span><span>&nbsp;java.lang.Exception;&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;TestException&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">static</span><span>&nbsp;</span><span class="keyword">int</span><span>&nbsp;quotient(</span><span class="keyword">int</span><span>&nbsp;x,&nbsp;</span><span class="keyword">int</span><span>&nbsp;y)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;MyException&nbsp;{&nbsp;</span><span class="comment">//&nbsp;定义方法抛出异常</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(y&nbsp;&lt;&nbsp;</span><span class="number">0</span><span>)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;判断参数是否小于0</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;</span><span class="keyword">new</span><span>&nbsp;MyException(</span><span class="string">"除数不能是负数"</span><span>);&nbsp;</span><span class="comment">//&nbsp;异常信息</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;x/y;&nbsp;</span><span class="comment">//&nbsp;返回值</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String&nbsp;args[])&nbsp;{&nbsp;</span><span class="comment">//&nbsp;主方法</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;&nbsp;a&nbsp;=</span><span class="number">3</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;&nbsp;b&nbsp;=</span><span class="number">0</span><span>;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;</span><span class="comment">//&nbsp;try语句包含可能发生异常的语句</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;result&nbsp;=&nbsp;quotient(a,&nbsp;b);&nbsp;</span><span class="comment">//&nbsp;调用方法quotient()</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(MyException&nbsp;e)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;处理自定义异常</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());&nbsp;<span class="comment">//&nbsp;输出异常信息</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(ArithmeticException&nbsp;e)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;处理ArithmeticException异常</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"除数不能为0"</span><span>);&nbsp;</span><span class="comment">//&nbsp;输出提示信息</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;处理其他异常</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class="string">"程序发生了其他的异常"</span><span>);&nbsp;</span><span class="comment">//&nbsp;输出提示信息</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">class</span><span>&nbsp;MyException&nbsp;</span><span class="keyword">extends</span><span>&nbsp;Exception&nbsp;{&nbsp;</span><span class="comment">//&nbsp;创建自定义异常类</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;message;&nbsp;<span class="comment">//&nbsp;定义String类型变量</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;MyException(String&nbsp;ErrorMessagr)&nbsp;{&nbsp;</span><span class="comment">//&nbsp;父类方法</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message&nbsp;=&nbsp;ErrorMessagr;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;String&nbsp;getMessage()&nbsp;{&nbsp;</span><span class="comment">//&nbsp;覆盖getMessage()方法</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;message;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol></div><pre code_snippet_id="456083" snippet_file_name="blog_20140822_14_856863" name="code" class="java" style="display: none;">package Test;
import java.lang.Exception;
public class TestException {
	static int quotient(int x, int y) throws MyException { // 定义方法抛出异常
		if (y &lt; 0) { // 判断参数是否小于0
			throw new MyException("除数不能是负数"); // 异常信息
		}
		return x/y; // 返回值
	}
	public static void main(String args[]) { // 主方法
		int  a =3;
		int  b =0; 
		try { // try语句包含可能发生异常的语句
			int result = quotient(a, b); // 调用方法quotient()
		} catch (MyException e) { // 处理自定义异常
			System.out.println(e.getMessage()); // 输出异常信息
		} catch (ArithmeticException e) { // 处理ArithmeticException异常
			System.out.println("除数不能为0"); // 输出提示信息
		} catch (Exception e) { // 处理其他异常
			System.out.println("程序发生了其他的异常"); // 输出提示信息
		}
	}

}
class MyException extends Exception { // 创建自定义异常类
	String message; // 定义String类型变量
	public MyException(String ErrorMessagr) { // 父类方法
		message = ErrorMessagr;
	}

	public String getMessage() { // 覆盖getMessage()方法
		return message;
	}
}</pre>
<p></p>
<p><span style="font-size:14px"><span style="color:#ff6600"><span style="color:rgb(51,51,255); font-family:Arial,宋体; font-size:16px; line-height:24px"><strong>4.3 异常链</strong></span><br>
</span></span></p>
<p><span style="font-size:14px"><span style="color:#ff6600">&nbsp; &nbsp; &nbsp; 1) 如果调用quotient(3,-1)</span><span style="color:#333333">，将发生MyException异常，程序调转到catch (MyException e)代码块中执行；<br>
</span></span></p>
<p><span style="font-size:14px"><span style="color:#333333">&nbsp; &nbsp; &nbsp; </span><span style="color:#ff6600">2) 如果调用quotient(5,0)</span><span style="color:#333333">，</span></span><span style="color:rgb(51,51,51); font-size:14px">将会因“除数为0”错误引发ArithmeticException异常，属于运行时异常类，由Java运行时系统自动抛出。<span style="color:rgb(255,102,0); font-size:14px">quotient</span>（）方法没有捕捉ArithmeticException异常，Java运行时系统将沿方法调用栈查到main方法，将抛出的异常上传至<span style="color:rgb(255,102,0); font-size:14px">quotient</span>（）方法的调用者：</span></p>
<p><span style="color:rgb(51,51,51); font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:rgb(51,51,51); font-size:14px">int result = quotient(a, b); // 调用方法quotient()</span><br style="color:rgb(51,51,51); font-size:14px">
<span style="color:rgb(51,51,51); font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp; 由于该语句在try监控区域内，因此传回的“除数为0”的ArithmeticException异常由Java运行时系统抛出，并匹配catch子句：</span></span></p>
<p><span style="color:rgb(51,51,51); font-size:14px"><span style="color:rgb(51,51,51); font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:rgb(51,51,51); font-size:14px"></span>catch (ArithmeticException e) { // 处理ArithmeticException异常<br>
<span style="white-space:pre"></span>System.out.println("除数不能为0"); // 输出提示信息<br>
<span style="white-space:pre"></span>}&nbsp;<span style="color:rgb(51,51,51); font-size:14px"></span></span></span></p>
<p><span style="font-size:14px"><span style="font-size:14px"><span style="color:#333333">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-size:14px"><span style="color:#333333">处理结果是输出“</span><span style="color:rgb(51,51,51); font-size:14px">除数不能为0</span><span style="color:#333333">”。Java这种向上传递异常信息的处理机制，</span><strong><span style="color:#3333ff">形成异常链</span></strong><span style="color:#333333">。</span></span></span></span></p>
<p><span style="color:rgb(51,51,51); font-size:14px"><span style="color:rgb(51,51,51); font-size:14px"><span style="color:rgb(51,51,51); font-size:14px">&nbsp; &nbsp; &nbsp; &nbsp;Java方法抛出的可查异常将依据调用栈、沿着方法调用的层次结构一直传递到具备处理能力的调用方法，最高层次到main方法为止。如果异常传递到main方法，而main不具备处理能力，也没有通过throws声明抛出该异常，将可能出现编译错误。</span></span></span></p>
<p></p>
<p><span style="line-height:24px"><span style="font-family:Simsun"><span style="font-size:14px; color:rgb(69,69,69); font-family:Arial,宋体; line-height:24px">&nbsp; &nbsp; &nbsp;</span><span style="font-size:14px"><span style="color:#ff6600"><span style="font-family:Arial,宋体; line-height:24px">&nbsp;</span><span style="font-family:Arial,宋体; line-height:24px">3)如还有其他异常发生</span></span><span style="color:rgb(69,69,69); font-family:Arial,宋体; line-height:24px">，将使用catch
 (Exception e)捕捉异常。由于Exception是所有异常类的父类，如果将catch (Exception e)代码块放在其他两个代码块的前面，后面的代码块将永远得不到执行，就没有什么意义了，所以catch语句的顺序不可掉换。</span></span></span></span></p>
<h3><a name="t11"></a><span style="background-color:rgb(255,255,255)"><span style="color:#3333ff"><span style="font-size:14px">4.4 Throwable类中的常用方法</span></span></span></h3>
<p><span style="color:rgb(69,69,69); background-color:rgb(255,255,255)"><span style="font-size:14px">注意：catch关键字后面括号中的Exception类型的参数e。Exception就是try代码块传递给catch代码块的变量类型，e就是变量名。catch代码块中语句"e.getMessage();"用于输出错误性质。通常异常处理常用3个函数来获取异常的有关信息:</span></span></p>
<span style="color:rgb(69,69,69); background-color:rgb(255,255,255)"><span style="font-size:14px"></span></span>
<p><span style="color:rgb(69,69,69)"><span style="font-size:14px">&nbsp; &nbsp; &nbsp;getCause()：返回抛出异常的原因。如果 cause 不存在或未知，则返回 null。</span></span></p>
<span style="color:rgb(69,69,69)"><span style="font-size:14px">　 getMeage()：返回异常的消息信息。<br>
</span></span>
<p><span style="color:rgb(69,69,69)"><span style="font-size:14px">　 printStackTrace()：对象的堆栈跟踪输出至错误输出流，作为字段 System.err 的值。</span></span></p>
<p><span style="color:rgb(69,69,69); background-color:rgb(255,255,255)"><span style="font-size:14px">&nbsp; &nbsp; &nbsp;有时为了简单会忽略掉catch语句后的代码，这样try-catch语句就成了一种摆设，一旦程序在运行过程中出现了异常，就会忽略处理异常，而错误发生的原因很难查找。</span></span></p>
<p><span style="color:rgb(69,69,69); background-color:rgb(255,255,255)"><span style="font-size:14px"><br>
</span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<div>
<h2 style="margin:0px; padding:0px; color:rgb(51,51,51); font-family:Arial; line-height:26px; text-align:left"><a name="t12"></a>
<p class="headline-1 bk-sidecatalog-title" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:6px; border-bottom-color:rgb(222,223,225); border-bottom-width:1px; border-bottom-style:solid; clear:both">
<span style="color:rgb(51,102,153)"><span style="line-height:36px; font-size:22px">&nbsp;5.Java常见异常</span></span></p>
</h2>
</div>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)">&nbsp;&nbsp;</span></p>
<p style="color:rgb(51,51,51)"><span style="font-size:14px">在Java中提供了一些异常用来描述经常发生的错误，对于这些异常，有的需要程序员进行捕获处理或声明抛出，有的是由Java虚拟机自动进行捕获处理。Java中常见的异常类:</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; line-height:14px">
</p>
<h3><a name="t13"></a><span style="background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; line-height:24px"><strong><span style="color:rgb(51,51,255)"><span style="font-size:14px">1. runtimeException子类:</span></span></strong></span></span></h3>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px"><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><strong>&nbsp;</strong></span> &nbsp; 1、 java.lang.ArrayIndexOutOfBoundsException<br>
</span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 数组索引越界异常。当对数组的索引值为负数或大于等于数组大小时抛出。<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 2、java.lang.ArithmeticException<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 算术条件异常。譬如：整数除零等。<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 3、java.lang.NullPointerException<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 空指针异常。当应用试图在要求使用对象的地方使用了null时，抛出该异常。譬如：调用null对象的实例方法、访问null对象的属性、计算null对象的长度、使用throw语句抛出null等等<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 4、java.lang.ClassNotFoundException<br>
</span></span><span style="color:rgb(69,69,69); font-size:14px; background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp; 找不到类异常。当应用试图根据字符串形式的类名构造类，而在遍历CLASSPAH之后找不到对应名称的class文件时，抛出该异常。</span></span>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"><span style="font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp;<span style="color:rgb(69,69,69); font-family:Arial,宋体; font-size:14px; line-height:24px">5、java.lang.<span style="color:rgb(51,51,51)">NegativeArraySizeException&nbsp;</span></span></span></span><span style="color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px">&nbsp;</span><span style="color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px">数组长度为负异常</span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px">&nbsp; &nbsp;6<span style="color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px"><span style="font-family:Arial,宋体; line-height:24px">、java.lang.<span style="color:rgb(51,51,51)"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">ArrayStoreException</span>&nbsp;</span></span></span><span style="font-size:14px; color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px"></span><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">数组中包含不兼容的值抛出的异常</span><span style="font-size:14px; color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px"></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp; &nbsp;7</span><span style="font-size:14px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; line-height:14px"><span style="font-family:Arial,宋体; line-height:24px">、java.lang.<span style="color:rgb(51,51,51)"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">SecurityException</span>&nbsp;</span></span></span><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">安全性异常</span></span><br>
</span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="color:rgb(51,51,51); font-family:Arial,宋体; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp;<span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">&nbsp;
 8</span><span style="font-size:14px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; line-height:14px"><span style="font-family:Arial,宋体; line-height:24px">、java.lang.<span style="color:rgb(51,51,51)"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">IllegalArgumentException</span>&nbsp;</span></span></span><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:Arial,宋体; font-size:14px; line-height:24px">非法参数异常</span></span></span></span></span></span></p>
</blockquote>
<h3><a name="t14"></a><span style="font-weight:bold"><span style="font-family:Arial,宋体; line-height:24px"><span style="font-family:宋体; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)"><span style="color:rgb(51,51,255)"><span style="font-size:14px">2.<span style="font-family:宋体; line-height:28px; text-indent:28px"><strong>IOException</strong></span></span></span></span></span></span></span></h3>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px; background-color:rgb(255,255,255)">IOException：操作输入流和输出流时可能出现的异常。</span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">EOFException &nbsp; 文件已结束异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">FileNotFoundException &nbsp; 文件未找到异常</span></span></span></p>
</blockquote>
<h3><a name="t15"></a><span style="font-family:Arial,宋体; line-height:24px"><span style="font-family:宋体; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)"><span style="color:rgb(51,51,255)"><span style="font-size:14px">3. 其他</span></span></span></span></span></h3>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">ClassCastException &nbsp; &nbsp;类型转换异常类</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">ArrayStoreException &nbsp;数组中包含不兼容的值抛出的异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">SQLException &nbsp; 操作数据库异常类</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">NoSuchFieldException &nbsp; 字段未找到异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">NoSuchMethodException &nbsp; 方法未找到抛出的异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">NumberFormatException &nbsp; &nbsp;字符串转换为数字抛出的异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">StringIndexOutOfBoundsException 字符串索引超出范围抛出的异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">IllegalAccessException &nbsp;不允许访问某类异常</span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="font-family:Arial,宋体; font-size:14px; line-height:24px"><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"><span style="background-color:rgb(255,255,255)">InstantiationException &nbsp;当应用程序试图使用Class类中的newInstance()方法创建一个类的实例，而指定的类对象无法被实例化时，抛出该异常</span></span></span></p>
</blockquote>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"><strong></strong></span></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; line-height:14px">
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<strong><span style="text-align:center; color:rgb(51,51,51); font-family:宋体; line-height:28px; text-indent:28px">&nbsp; &nbsp;&nbsp;</span></strong></p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<div>
<h2 style="margin:0px; padding:0px; color:rgb(51,51,51); font-family:Arial; line-height:26px; text-align:left"><a name="t16"></a>
<p class="headline-1 bk-sidecatalog-title" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:6px; border-bottom-color:rgb(222,223,225); border-bottom-width:1px; border-bottom-style:solid; clear:both">
<span style="color:rgb(51,102,153)"><span style="line-height:36px; font-size:22px">&nbsp;6.自定义异常</span></span></p>
</h2>
</div>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
</p>
<p style="margin-top:10px; margin-bottom:10px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); text-indent:28px; font-family:宋体; font-size:14px; line-height:28px">
使用Java内置的异常类可以描述在编程时出现的大部分异常情况。除此之外，用户还可以自定义异常。用户自定义异常类，只需继承Exception类即可。<br>
&nbsp; &nbsp; 在程序中使用自定义异常类，大体可分为以下几个步骤。<br>
（1）创建自定义异常类。<br>
（2）在方法中通过throw关键字抛出异常对象。<br>
（3）如果在当前抛出异常的方法中处理异常，可以使用try-catch语句捕获并处理；否则在方法的声明处通过throws关键字指明要抛出给方法调用者的异常，继续进行下一步操作。<br>
（4）在出现异常方法的调用者中捕获并处理异常。</p>
<p style="margin-top:10px; margin-bottom:10px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); text-indent:28px; font-family:宋体; font-size:14px; line-height:28px">
在上面的“使用throw抛出异常”例子已经提到了。</p>
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(69,69,69); font-family:tahoma,helvetica,arial; font-size:14px; line-height:14px">
<span style="background-color:rgb(255,255,255)"><br>
</span><br>
</p>
</div>




<!-- Baidu Button BEGIN -->

<div class="bdsharebuttonbox bdshare-button-style0-16" style="float: right;" data-bd-bind="1428455130162">
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important"></a>
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间" style="background-position:0 -52px !important"></a>
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博" style="background-position:0 -104px !important"></a>
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博" style="background-position:0 -260px !important"></a>
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_renren" data-cmd="renren" title="分享到人人网" style="background-position:0 -208px !important"></a>
<a href="http://blog.csdn.net/hguisu/article/details/6155636#" class="bds_weixin" data-cmd="weixin" title="分享到微信" style="background-position:0 -1612px !important"></a>
</div>
<script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
<!-- Baidu Button END -->

<!--192.168.100.36-->
<ul class="article_next_prev">
            <li class="prev_article"><span onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_shangyipian&#39;]);location.href=&#39;/hguisu/article/details/6152921&#39;;">上一篇</span><a href="http://blog.csdn.net/hguisu/article/details/6152921" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_shangyipian&#39;])">Linux 内存管理</a></li>
            <li class="next_article"><span onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_xiayipian&#39;]);location.href=&#39;/hguisu/article/details/6163621&#39;;">下一篇</span><a href="http://blog.csdn.net/hguisu/article/details/6163621" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_xiayipian&#39;])">Memcache存储大数据的问题</a></li>
</ul>

<!-- Baidu Button BEGIN -->
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/bds_s_v2.js"></script>

<script type="text/javascript">
    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->


        <div id="digg" articleid="6155636">
            <dl id="btnDigg" class="digg digg_disable">
                <dt onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_ding&#39;])">顶</dt>
                <dd>49</dd>
            </dl>
            <dl id="btnBury" class="digg digg_disable">
                <dt onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_cai&#39;])">踩</dt>
                <dd>1</dd>
            </dl>
        </div>
</div>
      <dl class="blog-associat-tag">
        <dt>主题推荐</dt>
        <dd>
                <a href="http://www.csdn.net/tag/%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86" target="_blank" class="blog-tage-red">异常处理</a> 
                <a href="http://www.csdn.net/tag/outofmemoryerror" target="_blank" class="blog-tage-red">outofmemoryerror</a> 
                <a href="http://www.csdn.net/tag/%E7%BC%96%E8%AF%91%E5%99%A8" target="_blank" class="blog-tage-red">编译器</a> 
                <a href="http://www.csdn.net/tag/%E8%AE%A1%E7%AE%97%E6%9C%BA" target="_blank" class="blog-tage-red">计算机</a> 
                <a href="http://www.csdn.net/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" target="_blank" class="blog-tage-red">数据库</a> 
        </dd>
    </dl> 


<dl class="blog-ass-articl tracking-ad" data-mod="popu_36" id="res-relatived"> 
     <dt><span>猜你在找</span></dt>    
<dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/a564663276/article/details/8964155" title="Java内部类总结 吐血之作" strategy="CFRecommendAlgorithm" target="_blank">Java内部类总结 吐血之作</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/igiqoanw/article/details/38386815" title="面试经验" strategy="CFRecommendAlgorithm" target="_blank">面试经验</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/zhanjianshinian/article/details/37815583" title="数据库设计中的14个技巧" strategy="CFRecommendAlgorithm" target="_blank">数据库设计中的14个技巧</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/aeolus1019/article/details/7974430" title="Cannot make a static reference to the non-static method的解决方法" strategy="CFRecommendAlgorithm" target="_blank">Cannot make a static reference to the non-static method的解决方法</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/smile0198/article/details/25567977" title="Spring MVC 简介" strategy="CFRecommendAlgorithm" target="_blank">Spring MVC 简介</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/rosenluo/article/details/40891245" title="分享45个android实例源码很好很强大收藏吧" strategy="CFRecommendAlgorithm" target="_blank">分享45个android实例源码很好很强大收藏吧</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/johnnywww/article/details/7964326" title="maven 打包可执行jar的方法" strategy="CFRecommendAlgorithm" target="_blank">maven 打包可执行jar的方法</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/youxin2012/article/details/8684797" title="cs硕士妹子找工作经历阿里人搜等互联网" strategy="CFRecommendAlgorithm" target="_blank">cs硕士妹子找工作经历阿里人搜等互联网</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/I2Cbus/article/details/21739261" title="Android如何完全调试framework层代码" strategy="CFRecommendAlgorithm" target="_blank">Android如何完全调试framework层代码</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/xinguan1267/article/details/19411685" title="Redis mysql应用" strategy="CFRecommendAlgorithm" target="_blank">Redis mysql应用</a></dd></dl>
<div id="job_blog_reco"><dl class="blog-ass-articl tracking-ad" data-mod="popu_72"><dt><span>准备好了么？&nbsp;<label class="po_blg_detail_tiao">跳</label><label class="po_blg_detail_ba">吧</label><label class="po_blg_detail_th">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;！</label></span><a href="http://job.csdn.net/" target="_blank" class="po_blg_more">更多职位尽在&nbsp;<label class="po_blg_detail_csdn">CSDN JOB</label></a></dt><dd class="po_blg_dd"><div class="po_blg_po"><a href="http://job.csdn.net/Job/Index?jobID=84664" title="高级Java工程师(大数据处理平台方向)" strategy="DetailRecommend" target="_blank">高级Java工程师(大数据处理平台方向)</a></div><div class="po_blg_company"><a href="http://pr.csdn.net/enterprise/ent_home?orgid=214112" title="精硕世纪科技（北京）有限公司" target="_blank">精硕世纪科技（北京）有限公司</a></div><label class="po_blg_separator">|</label><div class="po_blg_salary"><a href="http://job.csdn.net/Job/Index?jobID=84664" target="_blank">15-25K/月</a></div><a class="po_blg_iwant" href="http://job.csdn.net/Job/Index?jobID=84664" target="_blank">我要跳槽</a></dd><dd class="po_blg_dd"><div class="po_blg_po"><a href="http://job.csdn.net/Job/Index?jobID=82699" title="JAVA高级开发工程师" strategy="DetailRecommend" target="_blank">JAVA高级开发工程师</a></div><div class="po_blg_company"><a href="http://pr.csdn.net/enterprise/ent_home?orgid=435158" title="折800" target="_blank">折800</a></div><label class="po_blg_separator">|</label><div class="po_blg_salary"><a href="http://job.csdn.net/Job/Index?jobID=82699" target="_blank">15-30K/月</a></div><a class="po_blg_iwant" href="http://job.csdn.net/Job/Index?jobID=82699" target="_blank">我要跳槽</a></dd><dd class="po_blg_dd"><div class="po_blg_po"><a href="http://job.csdn.net/Job/Index?jobID=84365" title="Java高级开发工程师（福州）" strategy="DetailRecommend" target="_blank">Java高级开发工程师（福州）</a></div><div class="po_blg_company"><a href="http://pr.csdn.net/enterprise/ent_home?orgid=373348" title="福建星网锐捷网络有限公司" target="_blank">福建星网锐捷网络有限公司</a></div><label class="po_blg_separator">|</label><div class="po_blg_salary"><a href="http://job.csdn.net/Job/Index?jobID=84365" target="_blank">10-20K/月</a></div><a class="po_blg_iwant" href="http://job.csdn.net/Job/Index?jobID=84365" target="_blank">我要跳槽</a></dd><dd class="po_blg_dd"><div class="po_blg_po"><a href="http://job.csdn.net/Job/Index?jobID=82992" title="Java工程师" strategy="DetailRecommend" target="_blank">Java工程师</a></div><div class="po_blg_company"><a href="http://pr.csdn.net/enterprise/ent_home?orgid=423665" title="途牛旅游网" target="_blank">途牛旅游网</a></div><label class="po_blg_separator">|</label><div class="po_blg_salary"><a href="http://job.csdn.net/Job/Index?jobID=82992" target="_blank">2-20K/月</a></div><a class="po_blg_iwant" href="http://job.csdn.net/Job/Index?jobID=82992" target="_blank">我要跳槽</a></dd></dl></div>

<script type="text/javascript">
    var searchtitletags = '深入理解java异常处理机制' + ',' + '异常处理,outofmemoryerror,编译器,计算机,数据库';
    searchService({
        index: 'blog',
        query: searchtitletags,
        from: 10,
        size: 10,
        appendTo: '#res-relatived',
        url: 'recommend',
        his: 2,
        client: "blog_cf_enhance",
        tmpl: '<dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="#{ url }" title="#{ title }" strategy="#{ strategy }">#{ title }</a></dd>'
    });

 </script>   



    <div id="ad_cen">
   
          <script type="text/javascript">
              new Ad(4, 'ad_cen');
          </script>
    <iframe id="ad_frm_0" frameborder="0" scrolling="no" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad(1).html" style="border-width: 0px; overflow: hidden; width: 746px; height: 90px;"></iframe></div>
<div class="comment_class">
    <div id="comment_title" class="panel_head">
        <span class="see_comment">查看评论</span><a name="comments"></a></div>
    <div id="comment_list"><dl class="comment_item comment_topic" id="comment_item_4876733"><dt class="comment_head" floor="35">35楼 <span class="user"><a class="username" href="http://blog.csdn.net/Yl56F" target="_blank">Zempty9758</a> <span class="ptime">2015-03-25 19:59发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4876733" username="Yl56F"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/Yl56F" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_yl56f.jpg" width="40" height="40"></a></dd><dd class="comment_body">问题是我看到最后还是不知道何为正常处理异常？只是打印个异常栈错误信息就得了还是应该怎么做？</dd></dl><dl class="comment_item comment_topic" id="comment_item_4825807"><dt class="comment_head" floor="34">34楼 <span class="user"><a class="username" href="http://blog.csdn.net/liunian110110" target="_blank">liunian110110</a> <span class="ptime">2015-03-05 13:31发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4825807" username="liunian110110"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/liunian110110" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_liunian110110.jpg" width="40" height="40"></a></dd><dd class="comment_body">文章写得很详细，也很好。那张图片有点问题中间的那个ArrithmeticException，拼写错误，应该为ArithmeticException，多了个r。</dd></dl><dl class="comment_item comment_topic" id="comment_item_4731125"><dt class="comment_head" floor="33">33楼 <span class="user"><a class="username" href="http://blog.csdn.net/shenlan18446744" target="_blank">深蓝developer</a> <span class="ptime">2015-01-23 00:26发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4731125" username="shenlan18446744"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/shenlan18446744" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_shenlan18446744.jpg" width="40" height="40"></a></dd><dd class="comment_body">高手！顶礼膜拜！等哪天跳槽了，一定到你们公司面试。</dd></dl><dl class="comment_item comment_topic" id="comment_item_4706607"><dt class="comment_head" floor="32">32楼 <span class="user"><a class="username" href="http://blog.csdn.net/zhuangjixiang" target="_blank">风骚的裤脚</a> <span class="ptime">2015-01-13 14:35发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4706607" username="zhuangjixiang"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/zhuangjixiang" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_zhuangjixiang.jpg" width="40" height="40"></a></dd><dd class="comment_body">学习了</dd></dl><dl class="comment_item comment_topic" id="comment_item_4699085"><dt class="comment_head" floor="31">31楼 <span class="user"><a class="username" href="http://blog.csdn.net/ggbwqy242" target="_blank">ggbwqy242</a> <span class="ptime">2015-01-09 23:12发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4699085" username="ggbwqy242"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/ggbwqy242" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_ggbwqy242.jpg" width="40" height="40"></a></dd><dd class="comment_body">zanzan</dd></dl><dl class="comment_item comment_topic" id="comment_item_4688393"><dt class="comment_head" floor="30">30楼 <span class="user"><a class="username" href="http://blog.csdn.net/binghejinjun" target="_blank">binghejinjun</a> <span class="ptime">2015-01-06 16:21发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4688393" username="binghejinjun"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/binghejinjun" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_binghejinjun.jpg" width="40" height="40"></a></dd><dd class="comment_body">其实只要看了一楼的回复，答案就明了了，不过还是感谢楼主分享！</dd></dl><dl class="comment_item comment_topic" id="comment_item_4643321"><dt class="comment_head" floor="29">29楼 <span class="user"><a class="username" href="http://blog.csdn.net/Jaster_wisdom" target="_blank">Jaster_wisdom</a> <span class="ptime">2014-12-28 17:14发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4643321" username="Jaster_wisdom"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/Jaster_wisdom" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_jaster_wisdom.jpg" width="40" height="40"></a></dd><dd class="comment_body">哇哇，真的很详细，赞。</dd></dl><dl class="comment_item comment_topic" id="comment_item_4635979"><dt class="comment_head" floor="28">28楼 <span class="user"><a class="username" href="http://blog.csdn.net/l498948617" target="_blank">l498948617</a> <span class="ptime">2014-12-25 17:29发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4635979" username="l498948617"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/l498948617" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_l498948617.jpg" width="40" height="40"></a></dd><dd class="comment_body">不错，学习了~</dd></dl><dl class="comment_item comment_topic" id="comment_item_4582653"><dt class="comment_head" floor="27">27楼 <span class="user"><a class="username" href="http://blog.csdn.net/u011463799" target="_blank">yejiayanivy</a> <span class="ptime">2014-12-04 11:00发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4582653" username="u011463799"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u011463799" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u011463799.jpg" width="40" height="40"></a></dd><dd class="comment_body">好像有点错误哦，Exception下面的异常除了IOException和RuntimeExceptiom还有其他异常的，具体可以查API里面的Exception还有就是， Java异常类层次结构图中，ClassNotFoundException不是RuntimeException的吧，它是直接继承了Exception的啊</dd></dl><dl class="comment_item comment_topic" id="comment_item_4540687"><dt class="comment_head" floor="26">26楼 <span class="user"><a class="username" href="http://blog.csdn.net/allenhcool" target="_blank">allenhcool</a> <span class="ptime">2014-11-23 16:51发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4540687" username="allenhcool"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/allenhcool" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_allenhcool.jpg" width="40" height="40"></a></dd><dd class="comment_body">mark to my mind</dd></dl><dl class="comment_item comment_topic" id="comment_item_4510139"><dt class="comment_head" floor="25">25楼 <span class="user"><a class="username" href="http://blog.csdn.net/lyzsyr" target="_blank">lyzsyr</a> <span class="ptime">2014-11-12 17:06发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4510139" username="lyzsyr"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/lyzsyr" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_lyzsyr.jpg" width="40" height="40"></a></dd><dd class="comment_body">写的太好了</dd></dl><dl class="comment_item comment_topic" id="comment_item_4502083"><dt class="comment_head" floor="24">24楼 <span class="user"><a class="username" href="http://blog.csdn.net/csd_xuming" target="_blank">hanamingming</a> <span class="ptime">2014-11-10 11:35发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4502083" username="csd_xuming"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/csd_xuming" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_csd_xuming.jpg" width="40" height="40"></a></dd><dd class="comment_body">写的非常详细。 收藏。</dd></dl><dl class="comment_item comment_topic" id="comment_item_4489295"><dt class="comment_head" floor="23">23楼 <span class="user"><a class="username" href="http://blog.csdn.net/whatsis" target="_blank">whatsis</a> <span class="ptime">2014-11-05 20:05发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4489295" username="whatsis"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/whatsis" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_whatsis.jpg" width="40" height="40"></a></dd><dd class="comment_body">我是过来点赞的，写的好详细。</dd></dl><dl class="comment_item comment_topic" id="comment_item_4453087"><dt class="comment_head" floor="22">22楼 <span class="user"><a class="username" href="http://blog.csdn.net/cike8899" target="_blank">cike8899</a> <span class="ptime">2014-10-29 17:05发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4453087" username="cike8899"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/cike8899" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_cike8899.jpg" width="40" height="40"></a></dd><dd class="comment_body">try {  <br>      System.out.println (greetings[i]); i++;  <br>} <br>为什么i永远都等于3呢，为什么不会增加呢？<br>我是菜鸟，望大神指点！</dd><dl class="comment_item comment_reply" id="comment_item_4549197"><dt class="comment_head" floor="22">Re: <span class="user"><a class="username" href="http://blog.csdn.net/qq_20149545" target="_blank">qq_20149545</a> <span class="ptime">2014-11-26 08:03发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4549197" username="qq_20149545"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/qq_20149545" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_qq_20149545.jpg" width="40" height="40"></a></dd><dd class="comment_body">回复cike8899：没看 图2  图示try、catch、finally语句块的执行 ？<br>System.out.println (greetings[i]);出现异常后直接执行catch的语句，i++;被跳过了。可以把i++;放到打印语句前面试试<br>这篇文章写得很好</dd></dl><dl class="comment_item comment_reply" id="comment_item_4549185"><dt class="comment_head" floor="22">Re: <span class="user"><a class="username" href="http://blog.csdn.net/qq_20149545" target="_blank">qq_20149545</a> <span class="ptime">2014-11-26 07:35发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4549185" username="qq_20149545"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/qq_20149545" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_qq_20149545.jpg" width="40" height="40"></a></dd><dd class="comment_body">回复cike8899：没看 图2  图示try、catch、finally语句块的执行 ？<br>System.out.println (greetings[i]);出现异常后直接执行catch的语句，i++;被跳过了。可以把i++;放到打印语句前面试试<br>这篇文章写得很好</dd></dl></dl><dl class="comment_item comment_topic" id="comment_item_4427039"><dt class="comment_head" floor="21">21楼 <span class="user"><a class="username" href="http://blog.csdn.net/u012364351" target="_blank">kchiu</a> <span class="ptime">2014-10-23 10:10发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4427039" username="u012364351"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u012364351" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u012364351.jpg" width="40" height="40"></a></dd><dd class="comment_body">您写的太好了 互勉！！</dd></dl><dl class="comment_item comment_topic" id="comment_item_4418183"><dt class="comment_head" floor="20">20楼 <span class="user"><a class="username" href="http://blog.csdn.net/awoshiwo" target="_blank">awoshiwo</a> <span class="ptime">2014-10-21 11:15发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4418183" username="awoshiwo"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/awoshiwo" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_awoshiwo.jpg" width="40" height="40"></a></dd><dd class="comment_body">谢谢分享！mark是什么意思啊？</dd></dl><dl class="comment_item comment_topic" id="comment_item_4397691"><dt class="comment_head" floor="19">19楼 <span class="user"><a class="username" href="http://blog.csdn.net/jly4758" target="_blank">陈丽娜</a> <span class="ptime">2014-10-15 09:06发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4397691" username="jly4758"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/jly4758" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_jly4758.jpg" width="40" height="40"></a></dd><dd class="comment_body">这也太详细了！</dd></dl><dl class="comment_item comment_topic" id="comment_item_4389249"><dt class="comment_head" floor="18">18楼 <span class="user"><a class="username" href="http://blog.csdn.net/u010400728" target="_blank">KingAntY</a> <span class="ptime">2014-10-12 20:13发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4389249" username="u010400728"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u010400728" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u010400728.jpg" width="40" height="40"></a></dd><dd class="comment_body">楼主态度太认真了，可惜没看完，Mark一下</dd></dl><dl class="comment_item comment_topic" id="comment_item_4379615"><dt class="comment_head" floor="17">17楼 <span class="user"><a class="username" href="http://blog.csdn.net/yhzr_love_dandan" target="_blank">陈梦洲</a> <span class="ptime">2014-10-09 12:55发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4379615" username="yhzr_love_dandan"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/yhzr_love_dandan" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_yhzr_love_dandan.jpg" width="40" height="40"></a></dd><dd class="comment_body">写的非常棒！这是我第一次看完文章后专门登录再评论，以后应该多多说出自己的感谢，IT人的分享精神，值得称赞！</dd></dl><dl class="comment_item comment_topic" id="comment_item_4371411"><dt class="comment_head" floor="16">16楼 <span class="user"><a class="username" href="http://blog.csdn.net/fomeiherz" target="_blank">fomeiherz</a> <span class="ptime">2014-10-06 21:25发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4371411" username="fomeiherz"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/fomeiherz" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_fomeiherz.jpg" width="40" height="40"></a></dd><dd class="comment_body">写的很好，学习了。。。另外很喜欢你的头像</dd></dl><dl class="comment_item comment_topic" id="comment_item_4215139"><dt class="comment_head" floor="15">15楼 <span class="user"><a class="username" href="http://blog.csdn.net/u010644448" target="_blank">学习园</a> <span class="ptime">2014-08-26 21:21发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4215139" username="u010644448"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u010644448" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u010644448.jpg" width="40" height="40"></a></dd><dd class="comment_body">mark</dd></dl><dl class="comment_item comment_topic" id="comment_item_4199689"><dt class="comment_head" floor="14">14楼 <span class="user"><a class="username" href="http://blog.csdn.net/mc46790090" target="_blank">mc46790090</a> <span class="ptime">2014-08-21 20:28发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4199689" username="mc46790090"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/mc46790090" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_mc46790090.jpg" width="40" height="40"></a></dd><dd class="comment_body"><fieldset><legend>引用“cangchen”的评论：</legend>boolean testEx2() throws Exception {  <br>        boo...</fieldset><br>1楼已经回答了，finally中使用return会吃掉catch中抛出的异常。我也感觉博主写着写着把引子里的问题扔一边了。。。。不知道下面的看客是不是看着看着就被博主给带歪了，我找了全文都没有找到引子中的问题所在，感谢1楼，我做了实验，的确是的</dd><dl class="comment_item comment_reply" id="comment_item_4201243"><dt class="comment_head" floor="14">Re: <span class="user"><a class="username" href="http://blog.csdn.net/hguisu" target="_blank">真实的归宿</a> <span class="ptime">2014-08-22 10:02发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4201243" username="hguisu"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/hguisu" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_hguisu.jpg" width="40" height="40"></a></dd><dd class="comment_body">回复mc46790090：异常处理确实不应该出现return，谢谢。</dd></dl></dl><dl class="comment_item comment_topic" id="comment_item_4194429"><dt class="comment_head" floor="13">13楼 <span class="user"><a class="username" href="http://blog.csdn.net/dengzisheng" target="_blank">dengzisheng</a> <span class="ptime">2014-08-20 11:31发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4194429" username="dengzisheng"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/dengzisheng" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_dengzisheng.jpg" width="40" height="40"></a></dd><dd class="comment_body">写得太棒了，，，非常实用详细，，大赞LZ</dd></dl><dl class="comment_item comment_topic" id="comment_item_4172885"><dt class="comment_head" floor="12">12楼 <span class="user"><a class="username" href="http://blog.csdn.net/u011997289" target="_blank">just00play</a> <span class="ptime">2014-08-14 16:37发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4172885" username="u011997289"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u011997289" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u011997289.jpg" width="40" height="40"></a></dd><dd class="comment_body">学习了，thanks</dd></dl><dl class="comment_item comment_topic" id="comment_item_4109165"><dt class="comment_head" floor="11">11楼 <span class="user"><a class="username" href="http://blog.csdn.net/cangchen" target="_blank">cangchen</a> <span class="ptime">2014-07-31 11:04发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4109165" username="cangchen"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/cangchen" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_cangchen.jpg" width="40" height="40"></a></dd><dd class="comment_body">boolean testEx2() throws Exception {  <br>        boolean ret = true;  <br>        try {  <br>            int b = 12;  <br>            int c;  <br>            for (int i = 2; i &gt;= -2; i--) {  <br>                c = b / i;  <br>                System.out.println("i=" + i);  <br>            }  <br>            return true;  <br>        } catch (Exception e) {  <br>            System.out.println("testEx2, catch exception");  <br>            ret = false;  <br>            throw e;  <br>        }<br>请问，虽然在该方法里捕获了该异常，但throw e 向上层抛出的e对象，上层不处理吗？</dd><dl class="comment_item comment_reply" id="comment_item_4199707"><dt class="comment_head" floor="11">Re: <span class="user"><a class="username" href="http://blog.csdn.net/mc46790090" target="_blank">mc46790090</a> <span class="ptime">2014-08-21 20:41发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4199707" username="mc46790090"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/mc46790090" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_mc46790090.jpg" width="40" height="40"></a></dd><dd class="comment_body">回复cangchen：刚才翻了《Thinking in Java》书中提到，finally语句块中如果重新抛出异常，会覆盖掉之前try块中捕获的异常，finally块中使用return会丢失try块中捕获的异常，当然finally块中，不能同时出现抛出异常和return语句</dd><dl class="comment_item comment_reply" id="comment_item_4305121"><dt class="comment_head" floor="1">Re: <span class="user"><a class="username" href="http://blog.csdn.net/mc46790090" target="_blank">mc46790090</a> <span class="ptime">2014-09-19 23:21发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4305121" username="mc46790090"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/mc46790090" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_mc46790090.jpg" width="40" height="40"></a></dd><dd class="comment_body">回复mc46790090：抱歉，之前的留言可能给大家造成误解“finally块中，不能同时出现抛出异常和return语句”<br>今晚又做了实验，finally语句块中可以同时抛出异常和return语句，只不过不可以将某个语句置为不可达：<br>例如<br>for(int i = 0; i &lt; 4; i++){<br>     if(i == 2) throw new MyException("");<br>}<br>     return;<br>}<br>也是可以的，同try块，抛出异常之后，下面的return语句就不会执行了，不知道博主博文里面的<br>“在以下4种特殊情况下，finally块不会被执行：<br>1）在finally语句块中发生了异常。<br>”<br>这句话是不是表示finally不会被【完全】执行，运行时异常，在编译器是无法判断的。因此肯定是会执行的，只是执行会中断而已。再次感谢博主分享博文！</dd></dl></dl></dl><dl class="comment_item comment_topic" id="comment_item_4082783"><dt class="comment_head" floor="10">10楼 <span class="user"><a class="username" href="http://blog.csdn.net/sum__mer" target="_blank">sum__mer</a> <span class="ptime">2014-07-25 14:44发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4082783" username="sum__mer"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/sum__mer" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_sum__mer.jpg" width="40" height="40"></a></dd><dd class="comment_body">异常处理机制，写的太棒了，谢谢，学习中……</dd></dl><dl class="comment_item comment_topic" id="comment_item_4056447"><dt class="comment_head" floor="9">9楼 <span class="user"><a class="username" href="http://blog.csdn.net/wangxiaolongbob" target="_blank">SelfMedicated</a> <span class="ptime">2014-07-17 11:03发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4056447" username="wangxiaolongbob"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/wangxiaolongbob" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_wangxiaolongbob.jpg" width="40" height="40"></a></dd><dd class="comment_body">能干的人解决问题。智慧的人绕开问题(A clever person solves a problem. A wise person avoids it)<br><br>不是绕开吧？是避免让问题发生</dd></dl><dl class="comment_item comment_topic" id="comment_item_4026859"><dt class="comment_head" floor="8">8楼 <span class="user"><a class="username" href="http://blog.csdn.net/ttjjttjj1101" target="_blank">冲浪的水手</a> <span class="ptime">2014-07-08 00:00发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4026859" username="ttjjttjj1101"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/ttjjttjj1101" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_ttjjttjj1101.jpg" width="40" height="40"></a></dd><dd class="comment_body">Fuck，写的太好了，膜拜!!!</dd></dl><dl class="comment_item comment_topic" id="comment_item_4013713"><dt class="comment_head" floor="7">7楼 <span class="user"><a class="username" href="http://blog.csdn.net/u010240928" target="_blank">384410505</a> <span class="ptime">2014-07-02 11:58发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="4013713" username="u010240928"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u010240928" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u010240928.jpg" width="40" height="40"></a></dd><dd class="comment_body">mark</dd></dl><dl class="comment_item comment_topic" id="comment_item_3894689"><dt class="comment_head" floor="6">6楼 <span class="user"><a class="username" href="http://blog.csdn.net/simonssphy" target="_blank">simonssphy</a> <span class="ptime">2014-05-29 19:43发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="3894689" username="simonssphy"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/simonssphy" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_simonssphy.jpg" width="40" height="40"></a></dd><dd class="comment_body">很好很好！</dd></dl><dl class="comment_item comment_topic" id="comment_item_3765477"><dt class="comment_head" floor="5">5楼 <span class="user"><a class="username" href="http://blog.csdn.net/u011205806" target="_blank">以指代步</a> <span class="ptime">2014-04-23 10:58发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="3765477" username="u011205806"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/u011205806" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_u011205806.jpg" width="40" height="40"></a></dd><dd class="comment_body">讲的非常详细和系统、很好的文章、</dd></dl><dl class="comment_item comment_topic" id="comment_item_3740377"><dt class="comment_head" floor="4">4楼 <span class="user"><a class="username" href="http://blog.csdn.net/IT5858IT" target="_blank">Jesse_fishing</a> <span class="ptime">2014-04-14 21:15发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="3740377" username="IT5858IT"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/IT5858IT" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_it5858it.jpg" width="40" height="40"></a></dd><dd class="comment_body">不错！</dd></dl><dl class="comment_item comment_topic" id="comment_item_3739141"><dt class="comment_head" floor="3">3楼 <span class="user"><a class="username" href="http://blog.csdn.net/ZTAngel" target="_blank">ZTAngel</a> <span class="ptime">2014-04-14 15:06发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="3739141" username="ZTAngel"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/ZTAngel" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_ztangel.jpg" width="40" height="40"></a></dd><dd class="comment_body">学习ing</dd></dl><dl class="comment_item comment_topic" id="comment_item_3676433"><dt class="comment_head" floor="2">2楼 <span class="user"><a class="username" href="http://blog.csdn.net/qiyejunlintian" target="_blank">孤独涉世人</a> <span class="ptime">2014-03-30 18:17发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="3676433" username="qiyejunlintian"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/qiyejunlintian" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_qiyejunlintian.jpg" width="40" height="40"></a></dd><dd class="comment_body">写的很好，学习了。</dd></dl><dl class="comment_item comment_topic" id="comment_item_2564538"><dt class="comment_head" floor="1">1楼 <span class="user"><a class="username" href="http://blog.csdn.net/yongmi" target="_blank">yongmi</a> <span class="ptime">2013-03-23 20:20发表</span>  <a href="http://blog.csdn.net/hguisu/article/details/6155636#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="2564538" username="yongmi"> <a href="http://blog.csdn.net/hguisu/article/details/6155636#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/hguisu/article/details/6155636#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/yongmi" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/3_yongmi.jpg" width="40" height="40"></a></dd><dd class="comment_body">finally中使用return是一种很不好的编程风格，它会覆盖掉所有的其它返回，并且吃掉catch中抛出的异常。</dd></dl><div class="clear"></div></div>
    <div id="comment_bar" style="display: none;">
    </div>
    <div id="comment_form"><div class="guest_link">您还没有登录,请<a href="javascript:void(0);" onclick="javascript:loginbox();">[登录]</a>或<a href="http://passport.csdn.net/account/register?from=http%3A%2F%2Fblog.csdn.net%2Fhguisu%2Farticle%2Fdetails%2F6155636">[注册]</a></div></div>

    <div class="announce">
        * 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
</div>

<script type="text/javascript">
    var fileName = '6155636';
    var commentscount = 40;
    var islock = false
</script>
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/comment.js"></script>
    <div id="ad_bot">
    <iframe id="ad_frm_1" frameborder="0" scrolling="no" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad(2).html" style="border-width: 0px; overflow: hidden; width: 746px; height: 0px;"></iframe></div>
    <script type="text/javascript">
    new Ad(5, 'ad_bot');
    </script>
<div id="report_dialog">
</div>

<div id="d-top" style="bottom:60px;">
        <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
            <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/blog-icon-reply.png" alt="快速回复">
        </a>    

    <a id="d-top-a" class="btn btn-top backtop" style="display: none;" title="返回顶部" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_huidaodingbu&#39;])">         
         <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/top.png" alt="TOP">
    </a>
</div>
<script type="text/javascript">
    $(function ()
    {
        $("#ad_frm_0").height("90px");
        
        setTimeout(function(){
            $("#ad_frm_2").height("200px");
        },1000);
        
        /*
        if($("#comment_content").length>0)
        {
            $("#quick-reply").show();

            $("#quick-reply").click(function(){
                setEditorFocus();
            });
        }       
     
        var d_top = $('#d-top-a');

        document.onscroll = function ()
        {
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }
        }
        $('#d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
        */
    });
  
</script>
<style type="text/css">
    .tag_list
    {
        background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #D7CBC1;
        color: #000000;
        font-size: 12px;
        line-height: 20px;
        list-style: none outside none;
        margin: 10px 2% 0 1%;
        padding: 1px;
    }
    .tag_list h5
    {
        background: none repeat scroll 0 0 #E0DBD3;
        color: #47381C;
        font-size: 12px;
        height: 24px;
        line-height: 24px;
        padding: 0 5px;
        margin: 0;
    }
    .tag_list h5 a
    {
        color: #47381C;
    }
    .classify
    {
        margin: 10px 0;
        padding: 4px 12px 8px;
    }
    .classify a
    {
        margin-right: 20px;
        white-space: nowrap;
    }
</style>
<div class="tag_list">
    <h5>
        <a href="http://www.csdn.net/tag/" target="_blank">核心技术类目</a></h5>
    <div class="classify">
<a title="全部主题" href="http://www.csdn.net/tag" target="_blank" onclick="LogClickCount(this,336);">全部主题</a>
<a title="Hadoop" href="http://g.csdn.net/5272865" target="_blank" onclick="LogClickCount(this,336);">Hadoop</a>
<a title="AWS" href="http://g.csdn.net/5272866" target="_blank" onclick="LogClickCount(this,336);">AWS</a>
<a title="移动游戏" href="http://g.csdn.net/5272870" target="_blank" onclick="LogClickCount(this,336);">移动游戏</a>
<a title="Java" href="http://g.csdn.net/5272871" target="_blank" onclick="LogClickCount(this,336);">Java</a>
<a title="Android" href="http://g.csdn.net/5272872" target="_blank" onclick="LogClickCount(this,336);">Android</a>
<a title="iOS" href="http://g.csdn.net/5272873" target="_blank" onclick="LogClickCount(this,336);">iOS</a>
<a title="Swift" href="http://g.csdn.net/5272868" target="_blank" onclick="LogClickCount(this,336);">Swift</a>
<a title="智能硬件" href="http://g.csdn.net/5272869" target="_blank" onclick="LogClickCount(this,336);">智能硬件</a>
<a title="Docker" href="http://g.csdn.net/5272867" target="_blank" onclick="LogClickCount(this,336);">Docker</a>
<a title="OpenStack" href="http://g.csdn.net/5272925" target="_blank" onclick="LogClickCount(this,336);">OpenStack</a>
<a title="VPN" href="http://www.csdn.net/tag/vpn" target="_blank" onclick="LogClickCount(this,336);">VPN</a>
<a title="Spark" href="http://g.csdn.net/5272924" target="_blank" onclick="LogClickCount(this,336);">Spark</a>
<a title="ERP" href="http://www.csdn.net/tag/erp" target="_blank" onclick="LogClickCount(this,336);">ERP</a>
<a title="IE10" href="http://www.csdn.net/tag/ie10" target="_blank" onclick="LogClickCount(this,336);">IE10</a>
<a title="Eclipse" href="http://www.csdn.net/tag/eclipse" target="_blank" onclick="LogClickCount(this,336);">Eclipse</a>
<a title="CRM" href="http://www.csdn.net/tag/crm" target="_blank" onclick="LogClickCount(this,336);">CRM</a>
<a title="JavaScript" href="http://www.csdn.net/tag/javascript" target="_blank" onclick="LogClickCount(this,336);">JavaScript</a>
<a title="数据库" href="http://www.csdn.net/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" target="_blank" onclick="LogClickCount(this,336);">数据库</a>
<a title="Ubuntu" href="http://www.csdn.net/tag/ubuntu" target="_blank" onclick="LogClickCount(this,336);">Ubuntu</a>
<a title="NFC" href="http://www.csdn.net/tag/nfc" target="_blank" onclick="LogClickCount(this,336);">NFC</a>
<a title="WAP" href="http://www.csdn.net/tag/wap" target="_blank" onclick="LogClickCount(this,336);">WAP</a>
<a title="jQuery" href="http://www.csdn.net/tag/jquery" target="_blank" onclick="LogClickCount(this,336);">jQuery</a>
<a title="BI" href="http://www.csdn.net/tag/bi" target="_blank" onclick="LogClickCount(this,336);">BI</a>
<a title="HTML5" href="http://www.csdn.net/tag/html5" target="_blank" onclick="LogClickCount(this,336);">HTML5</a>
<a title="Spring" href="http://www.csdn.net/tag/spring" target="_blank" onclick="LogClickCount(this,336);">Spring</a>
<a title="Apache" href="http://www.csdn.net/tag/apache" target="_blank" onclick="LogClickCount(this,336);">Apache</a>
<a title=".NET" href="http://www.csdn.net/tag/.net" target="_blank" onclick="LogClickCount(this,336);">.NET</a>
<a title="API" href="http://www.csdn.net/tag/api" target="_blank" onclick="LogClickCount(this,336);">API</a>
<a title="HTML" href="http://www.csdn.net/tag/html" target="_blank" onclick="LogClickCount(this,336);">HTML</a>
<a title="SDK" href="http://www.csdn.net/tag/sdk" target="_blank" onclick="LogClickCount(this,336);">SDK</a>
<a title="IIS" href="http://www.csdn.net/tag/iis" target="_blank" onclick="LogClickCount(this,336);">IIS</a>
<a title="Fedora" href="http://www.csdn.net/tag/fedora" target="_blank" onclick="LogClickCount(this,336);">Fedora</a>
<a title="XML" href="http://www.csdn.net/tag/xml" target="_blank" onclick="LogClickCount(this,336);">XML</a>
<a title="LBS" href="http://www.csdn.net/tag/lbs" target="_blank" onclick="LogClickCount(this,336);">LBS</a>
<a title="Unity" href="http://www.csdn.net/tag/unity" target="_blank" onclick="LogClickCount(this,336);">Unity</a>
<a title="Splashtop" href="http://www.csdn.net/tag/splashtop" target="_blank" onclick="LogClickCount(this,336);">Splashtop</a>
<a title="UML" href="http://www.csdn.net/tag/uml" target="_blank" onclick="LogClickCount(this,336);">UML</a>
<a title="components" href="http://www.csdn.net/tag/components" target="_blank" onclick="LogClickCount(this,336);">components</a>
<a title="Windows Mobile" href="http://www.csdn.net/tag/windowsmobile" target="_blank" onclick="LogClickCount(this,336);">Windows Mobile</a>
<a title="Rails" href="http://www.csdn.net/tag/rails" target="_blank" onclick="LogClickCount(this,336);">Rails</a>
<a title="QEMU" href="http://www.csdn.net/tag/qemu" target="_blank" onclick="LogClickCount(this,336);">QEMU</a>
<a title="KDE" href="http://www.csdn.net/tag/kde" target="_blank" onclick="LogClickCount(this,336);">KDE</a>
<a title="Cassandra" href="http://www.csdn.net/tag/cassandra" target="_blank" onclick="LogClickCount(this,336);">Cassandra</a>
<a title="CloudStack" href="http://www.csdn.net/tag/cloudstack" target="_blank" onclick="LogClickCount(this,336);">CloudStack</a>
<a title="FTC" href="http://www.csdn.net/tag/ftc" target="_blank" onclick="LogClickCount(this,336);">FTC</a>
<a title="coremail" href="http://www.csdn.net/tag/coremail" target="_blank" onclick="LogClickCount(this,336);">coremail</a>
<a title="OPhone " href="http://www.csdn.net/tag/ophone" target="_blank" onclick="LogClickCount(this,336);">OPhone </a>
<a title="CouchBase" href="http://www.csdn.net/tag/couchbase" target="_blank" onclick="LogClickCount(this,336);">CouchBase</a>
<a title="云计算" href="http://www.csdn.net/tag/%E4%BA%91%E8%AE%A1%E7%AE%97" target="_blank" onclick="LogClickCount(this,336);">云计算</a>
<a title="iOS6" href="http://www.csdn.net/tag/iOS6" target="_blank" onclick="LogClickCount(this,336);">iOS6</a>
<a title="Rackspace " href="http://www.csdn.net/tag/rackspace" target="_blank" onclick="LogClickCount(this,336);">Rackspace </a>
<a title="Web App" href="http://www.csdn.net/tag/webapp" target="_blank" onclick="LogClickCount(this,336);">Web App</a>
<a title="SpringSide" href="http://www.csdn.net/tag/springside" target="_blank" onclick="LogClickCount(this,336);">SpringSide</a>
<a title="Maemo" href="http://www.csdn.net/tag/maemo" target="_blank" onclick="LogClickCount(this,336);">Maemo</a>
<a title="Compuware" href="http://www.csdn.net/tag/compuware" target="_blank" onclick="LogClickCount(this,336);">Compuware</a>
<a title="大数据" href="http://www.csdn.net/tag/%E5%A4%A7%E6%95%B0%E6%8D%AE" target="_blank" onclick="LogClickCount(this,336);">大数据</a>
<a title="aptech" href="http://www.csdn.net/tag/aptech" target="_blank" onclick="LogClickCount(this,336);">aptech</a>
<a title="Perl" href="http://www.csdn.net/tag/perl" target="_blank" onclick="LogClickCount(this,336);">Perl</a>
<a title="Tornado" href="http://www.csdn.net/tag/tornado" target="_blank" onclick="LogClickCount(this,336);">Tornado</a>
<a title="Ruby" href="http://www.csdn.net/tag/ruby" target="_blank" onclick="LogClickCount(this,336);">Ruby</a>
<a title="Hibernate" href="http://www.csdn.net/hibernate" target="_blank" onclick="LogClickCount(this,336);">Hibernate</a>
<a title="ThinkPHP" href="http://www.csdn.net/tag/thinkphp" target="_blank" onclick="LogClickCount(this,336);">ThinkPHP</a>
<a title="HBase" href="http://www.csdn.net/tag/hbase" target="_blank" onclick="LogClickCount(this,336);">HBase</a>
<a title="Pure" href="http://www.csdn.net/tag/pure" target="_blank" onclick="LogClickCount(this,336);">Pure</a>
<a title="Solr" href="http://www.csdn.net/tag/solr" target="_blank" onclick="LogClickCount(this,336);">Solr</a>
<a title="Angular" href="http://www.csdn.net/tag/angular" target="_blank" onclick="LogClickCount(this,336);">Angular</a>
<a title="Cloud Foundry" href="http://www.csdn.net/tag/cloudfoundry" target="_blank" onclick="LogClickCount(this,336);">Cloud Foundry</a>
<a title="Redis" href="http://www.csdn.net/tag/redis" target="_blank" onclick="LogClickCount(this,336);">Redis</a>
<a title="Scala" href="http://www.csdn.net/tag/scala" target="_blank" onclick="LogClickCount(this,336);">Scala</a>
<a title="Django" href="http://www.csdn.net/tag/django" target="_blank" onclick="LogClickCount(this,336);">Django</a>
<a title="Bootstrap" href="http://www.csdn.net/tag/bootstrap" target="_blank" onclick="LogClickCount(this,336);">Bootstrap</a>
    </div>
</div>

<div id="pop_win" style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);">
    
</div>
<div id="popup_mask"></div>
<style>
    #popup_mask
    {
        position: absolute;
        width: 100%;
        height: 100%;
        background: #000;
        z-index: 9999;
        left: 0px;
        top: 0px;
        opacity: 0.3;
        filter: alpha(opacity=30);
        display: none;
    }

</style>




<script type="text/javascript">
    $(function(){
        setTimeout(function(){
            $(".comment_body:contains('回复')").each(function(index,item){
                var u=$(this).text().split('：')[0].toString().replace("回复","")
                var thisComment=$(this);
                if(u)
                {
                    $.getJSON("https://passport.csdn.net/get/nick?callback=?", {users: u}, function(a) {
                        if(a!=null&&a.data!=null&&a.data.length>0)
                        {
                            nick=a.data[0].n; 
                            if(u!=nick)
                            {
                                thisComment.text(thisComment.text().replace(u,nick));  
                            }
                        }       
                    });  
                }
            });
        },200);  
        
        setTimeout(function(){
            $("a img[src='http://js.tongji.linezing.com/stats.gif']").parent().css({"position":"absolute","left":"50%"});
        },300);
    });

    function loginbox(){
        var $logpop=$("#pop_win");
        $logpop.html('<iframe src="https://passport.csdn.net/account/loginbox?service=http://static.blog.csdn.net/callback.htm" frameborder="0" height="600" width="400" scrolling="no"></iframe>');

        $('#popup_mask').css({
            opacity: 0.5,
            width: $( document ).width() + 'px',
            height:  $( document ).height() + 'px'
        });
        $('#popup_mask').css("display","block");
 
        $logpop.css( {
            top: ($( window ).height() - $logpop.height())/ 2  + $( window 
       ).scrollTop() + 'px',
            left:($( window ).width() - $logpop.width())/ 2
        } );
 
        setTimeout( function () {
            $logpop.show();
            $logpop.css( {
                opacity: 1
            } );
        }, 200 );
 
        $('#popup_mask').unbind("click");
        $('#popup_mask').bind("click", function(){
            $('#popup_mask').hide();
            var $clopop = $("#pop_win");
            $("#common_ask_div_sc").css("display","none");
            $clopop.css( {
                opacity: 0
            } );
            setTimeout( function () {
                $clopop.hide();
            }, 350 );
            return false;
        });
    }    

</script>
                        <div class="clear">
                        </div>
                    </div>                   
                
            </div>
            <div id="side">
    <div class="side">


<div id="custom_column_37898201" class="panel">
<ul class="panel_head"><span>友情链接</span></ul>
<ul class="panel_body">

诚聘：http://job.csdn.net/job/index?jobID=81336

</ul>
</div><div id="panel_Profile" class="panel">
<ul class="panel_head"><span>个人资料</span></ul>
<ul class="panel_body profile">
<div id="blog_userface">
    <a href="http://my.csdn.net/hguisu" target="_blank">
    <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/1_hguisu.jpg" title="访问我的空间" style="max-width:90%">
    </a>
    <br>
    <span><a href="http://my.csdn.net/hguisu" class="user_name" target="_blank">真实的归宿</a></span>
</div>
<div class="interact">
<a href="javascript:void(0);" class="attent" id="span_add_follow" title="[加关注]" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_guanzhu&#39;])"></a>

 <a href="javascript:void(0);" class="letter" title="[发私信]" onclick="window.open(&#39;http://msg.csdn.net/letters/model?receiver=hguisu&#39;,&#39;_blank&#39;,&#39;height=350,width=700&#39;);_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_sixin&#39;])"></a>  
</div>
<div id="blog_medal">
                <div id="bms_box">
               </div>
</div>
<ul id="blog_rank">
    <li>访问：<span>1974952次</span></li>
    <li>积分：<span>17911</span> </li>    
    <li>等级： <span style="position:relative;display:inline-block;z-index:1">
            <img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/blog7.png" alt="" style="vertical-align: middle;" id="leveImg">
            <div id="smallTittle" style=" position: absolute;  left: -24px;  top: 25px;  text-align: center;  width: 101px;  height: 32px;  background-color: #fff;  line-height: 32px;  border: 2px #DDDDDD solid;  box-shadow: 0px 2px 2px rgba (0,0,0,0.1);  display: none;   z-index: 999;">
            <div style="left: 42%;  top: -8px;  position: absolute;  width: 0;  height: 0;  border-left: 10px solid transparent;  border-right: 10px solid transparent;  border-bottom: 8px solid #EAEAEA;"></div>
            积分：17911 </div>
        </span>  </li>
    <li>排名：<span>第192名</span></li>
</ul>
<ul id="blog_statistics">
    <li>原创：<span>205篇</span></li>
    <li>转载：<span>0篇</span></li>
    <li>译文：<span>0篇</span></li>
    <li>评论：<span>769条</span></li>
</ul>
</ul>
</div>



<div id="panel_Category" class="panel">
<ul class="panel_head"><span>文章分类</span></ul>
<ul class="panel_body">
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1253451" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">操作系统</a><span>(5)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/796967" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">Linux</a><span>(20)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/796963" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">MySQL</a><span>(12)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/796962" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">PHP</a><span>(41)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1104862" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">PHP内核</a><span>(11)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/796968" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">技术人生</a><span>(7)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1054628" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">数据结构与算法</a><span>(29)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1072794" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">云计算hadoop</a><span>(24)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1075597" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">网络知识</a><span>(7)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1080443" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">c/c++</a><span>(23)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1099674" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">memcache</a><span>(5)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1111071" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">HipHop</a><span>(2)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1112019" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">计算机原理</a><span>(4)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1114530" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">Java</a><span>(7)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1122753" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">socket网络编程</a><span>(8)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1133340" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">设计模式</a><span>(26)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1151353" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">AOP</a><span>(2)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1152364" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">重构</a><span>(11)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1173389" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">重构与模式</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1209788" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">大数据处理</a><span>(12)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1230933" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">搜索引擎Search Engine</a><span>(15)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1302430" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">HTML5</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1309674" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">Android</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1422000" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">webserver</a><span>(3)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1429288" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">NOSQL</a><span>(7)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1825837" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">NOSQL Mongo</a><span>(0)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/1868795" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">分布式</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/2065283" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">数据结构与算法  xi</a><span>(0)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/2065287" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">协议</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/2294375" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">信息论的熵</a><span>(0)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/2482451" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">关于php的libevent扩展的应用</a><span>(0)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/hguisu/article/category/2482459" onclick="_gaq.push([&#39;_trackEvent&#39;,&#39;function&#39;, &#39;onclick&#39;, &#39;blog_articles_wenzhangfenlei&#39;]); ">libevent简单介绍</a><span>(0)</span>
            </li>
</ul>
</div><div id="panel_Archive" class="panel">
<ul class="panel_head"><span>文章存档</span></ul>
<ul class="panel_body">
<div id="archive_list"><li><a href="http://blog.csdn.net/hguisu/article/month/2015/01">2015年01月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/10">2014年10月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/09">2014年09月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/08">2014年08月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/05">2014年05月</a><span>(1)</span></li><span class="hidelist" style="display:none;"><li><a href="http://blog.csdn.net/hguisu/article/month/2014/03">2014年03月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/02">2014年02月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2014/01">2014年01月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/12">2013年12月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/10">2013年10月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/09">2013年09月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/08">2013年08月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/07">2013年07月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/06">2013年06月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/05">2013年05月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/03">2013年03月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/02">2013年02月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2013/01">2013年01月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/12">2012年12月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/11">2012年11月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/10">2012年10月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/09">2012年09月</a><span>(15)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/08">2012年08月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/07">2012年07月</a><span>(8)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/06">2012年06月</a><span>(14)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/05">2012年05月</a><span>(29)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/04">2012年04月</a><span>(26)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/03">2012年03月</a><span>(27)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2012/02">2012年02月</a><span>(18)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2011/12">2011年12月</a><span>(7)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2011/01">2011年01月</a><span>(8)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2010/07">2010年07月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/hguisu/article/month/2007/12">2007年12月</a><span>(2)</span></li></span><div id="archive_list_button" class="list_closed">展开</div></div>
</ul>
</div>
<div id="hotarticls" class="panel">
<ul class="panel_head">
    <span>       
阅读排行    </span>
</ul>

<ul class="panel_body itemlist">
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7776068" title="八大排序算法">八大排序算法</a><span>(106280)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/5731880" title="Mysql 多表联合查询效率分析及优化">Mysql 多表联合查询效率分析及优化</a><span>(105140)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7244413" title="hbase安装配置（整合到hadoop）">hbase安装配置（整合到hadoop）</a><span>(67100)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7453390" title="socket阻塞与非阻塞，同步与异步、I/O模型">socket阻塞与非阻塞，同步与异步、I/O模型</a><span>(64362)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7237395" title="Hadoop集群配置（最全面总结）">Hadoop集群配置（最全面总结）</a><span>(49000)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/8930668" title="Nginx工作原理和优化、漏洞。">Nginx工作原理和优化、漏洞。</a><span>(47548)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7558249" title="设计模式 ( 十八 ) 策略模式Strategy（对象行为型）">设计模式 ( 十八 ) 策略模式Strategy（对象行为型）</a><span>(44021)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7418161" title="Java输入输出流">Java输入输出流</a><span>(42226)</span>
</li>
<li>
<a href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET.html" title="深入理解java异常处理机制">深入理解java异常处理机制</a><span>(41105)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7996185" title="PageRank算法">PageRank算法</a><span>(38962)</span>
</li>
</ul>
</div>
<div id="hotarticls2" class="panel">
<ul class="panel_head"><span>评论排行</span></ul>
<ul class="panel_body itemlist">
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7776068" title="八大排序算法">八大排序算法</a><span>(44)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7453390" title="socket阻塞与非阻塞，同步与异步、I/O模型">socket阻塞与非阻塞，同步与异步、I/O模型</a><span>(44)</span>
</li>
<li>
<a href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET.html" title="深入理解java异常处理机制">深入理解java异常处理机制</a><span>(40)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7558249" title="设计模式 ( 十八 ) 策略模式Strategy（对象行为型）">设计模式 ( 十八 ) 策略模式Strategy（对象行为型）</a><span>(35)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7408047" title="硬盘的读写原理">硬盘的读写原理</a><span>(31)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7880288" title="海量数据处理算法—Bit-Map">海量数据处理算法—Bit-Map</a><span>(24)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7505909" title="设计模式（一）工厂模式Factory（创建型）">设计模式（一）工厂模式Factory（创建型）</a><span>(23)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7448528" title="PHP SOCKET编程">PHP SOCKET编程</a><span>(22)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7609483" title="UML图中类之间的关系:依赖,泛化,关联,聚合,组合,实现">UML图中类之间的关系:依赖,泛化,关联,聚合,组合,实现</a><span>(20)</span>
</li>
<li>
<a href="http://blog.csdn.net/hguisu/article/details/7259716" title="HDFS写入和读取流程">HDFS写入和读取流程</a><span>(20)</span>
</li>
</ul>
</div>
<div id="homepageArticles" class="panel tracking-ad" data-mod="popu_4">
<ul class="panel_head"><span>推荐文章</span></ul>
<ul class="panel_body" id="ad_commend"><iframe id="ad_frm_2" frameborder="0" scrolling="no" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad.html" style="border-width: 0px; overflow: hidden; width: 182px; height: 200px;"></iframe></ul>
</div>
<script type="text/javascript">
 new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body itemlist">
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7418161#comments">Java输入输出流</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/strongyoung88" class="user_name">strongyoung88</a>:
博主，6.1有张图有误。Writer--OutputStreamWriter--FileWriter...
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7651730#comments">php的serialize序列化和json性能测试</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/cjqh_hao" class="user_name">cjqh_hao</a>:
lz，1楼提出的问题，你是否修改了，我看不出来哪有问题，请指教
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7106394#comments">字符编码详解及由来</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7106394#comments">字符编码详解及由来</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7719428#comments">图的应用详解-数据结构</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7719428#comments">图的应用详解-数据结构</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7408047#comments">硬盘的读写原理</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7408047#comments">硬盘的读写原理</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
学习了
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7408047#comments">硬盘的读写原理</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
谢谢楼主分享
    </p>
    </li>
    <li>
   
         <a href="http://blog.csdn.net/hguisu/article/details/7408047#comments">硬盘的读写原理</a>
    <p style="margin:0px;"><a href="http://blog.csdn.net/u014082714" class="user_name">liuhmmjj</a>:
非常详细
    </p>
    </li>
</ul>
</div>


<div id="custom_column_36736957" class="panel">
<ul class="panel_head"><span>友情链接</span></ul>
<ul class="panel_body">

<a href="http://www.tuling123.com/" target="_blank">图灵机器人：聊天api的最佳选择</a>

</ul>
</div>    </div>
    <div class="clear">
    </div>
</div>

            <div class="clear">
            </div>
        </div>
        

<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/cnick.js"></script>
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/newblog.min.js"></script>


<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/showblogmedal.ashx"></script>
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/JavaScript1.js"></script><link rel="stylesheet" type="text/css" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/pub_footer_2014.css"><div class="pub_fo"><div id="pub_footerall" class="pub_footer_new"><dl><dt></dt> <dd class="foot_sub_menu"><a href="http://www.csdn.net/company/about.html" target="_blank">公司简介</a><span>|</span><a href="http://www.csdn.net/company/recruit.html" target="_blank">招贤纳士</a><span>|</span><a href="http://www.csdn.net/company/marketing.html" target="_blank">广告服务</a><span>|</span><a href="http://www.csdn.net/company/account.html" target="_blank">银行汇款帐号</a><span>|</span><a href="http://www.csdn.net/company/contact.html" target="_blank">联系方式</a><span>|</span><a href="http://www.csdn.net/company/statement.html" target="_blank">版权声明</a><span>|</span><a href="http://www.csdn.net/company/layer.html" target="_blank">法律顾问</a><span>|</span><a href="mailto:webmaster@csdn.net">问题报告</a><span>|</span><a target="_blank" href="http://www.csdn.net/friendlink.html">合作伙伴</a><span>|</span><a href="http://bbs.csdn.net/forums/Service" target="_blank">论坛反馈</a></dd><dd class="foot_contact"><a href="http://wpa.qq.com/msgrd?v=3&uin=2355263776&site=qq&menu=yes" target="_blank" class="qq">网站客服</a><a href="http://wpa.qq.com/msgrd?v=3&uin=2251809102&site=qq&menu=yes" target="_blank" class="qq">杂志客服</a><a href="http://e.weibo.com/csdnsupport/profile" target="_blank" class="weibo">微博客服</a><a href="mailto:webmaster@csdn.net" class="email" title="联系邮箱">webmaster@csdn.net</a><span class="phone" title="服务热线">400-600-2320</span><span class="interval">|</span><span>北京创新乐知信息技术有限公司 版权所有</span><span class="interval">|</span><span>江苏乐知网络技术有限公司 提供商务支持</span></dd><dd class="foot_copyright"><span>京&nbsp;ICP&nbsp;证&nbsp;070598&nbsp;号</span><span class="interval">|</span><span>Copyright © 1999-2014, CSDN.NET, All Rights Reserved&nbsp;</span><a href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010" target="_blank"><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/gongshang_logos.gif" alt="GongshangLogo" title=""></a></dd></dl></div></div><div id="note1" class="csdn_note" style="display:none; position:absolute; z-index:9999; width:440px">  <span class="notice_top_arrow"><span class="inner"></span></span>  <div class="box"></div></div><div class="csdn_notice_tip" style="display: none; position: absolute; z-index: 9990; width: 170px;">  <iframe src="about:blank" frameborder="0" scrolling="no" style="z-index:-1;position:absolute;top:0;left:0;width:100%;height:100%;background:transparent"></iframe>  <div class="tip_text">您有<strong>0</strong>条新通知</div>  <a href="javascript:void 0" class="close2"></a></div><script id="noticeScript" type="text/javascript" btnid="header_notice_num" wrapid="note1" count="5" subcount="5" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/notify.js"></script>

    <script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/login.js"></script>
<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/pv.aspx" border="0" width="0" height="0">
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/counter.js"></script><script type="text/javascript" charset="UTF-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/msg.popup.js"></script>
<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad-blog.js"></script><script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ad-ms1275.js"></script>

<script type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/count.js"></script><iframe src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/logs.html" frameborder="0" width="0" height="0"></iframe>
<script type="text/javascript">
    $(function () {
        function __get_code_toolbar(snippet_id) {
            return $("<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "' target='_blank' title='在CODE上查看代码片' style='text-indent:0;'><img src='https://code.csdn.net/assets/CODE_ico.png' width=12 height=12 alt='在CODE上查看代码片' style='position:relative;top:1px;left:2px;'/></a>"
                    + "<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "/fork' target='_blank' title='派生到我的代码片'  style='text-indent:0;'><img src='https://code.csdn.net/assets/ico_fork.svg' width=12 height=12 alt='派生到我的代码片' style='position:relative;top:2px;left:2px;'/></a>");
        }
        
        $("[code_snippet_id]").each(function () {
            __s_id = $(this).attr("code_snippet_id");
            if (__s_id != null && __s_id != "" && __s_id != 0 && parseInt(__s_id) > 70020) {
                __code_tool = __get_code_toolbar(__s_id);
                $(this).prev().find(".tools").append(__code_tool);
            }
        });
    });
</script>

    </div><input type="hidden" id="aa_g_data_ids">
      <!--new top-->
    
    <script id="csdn-toolbar-id" btnid="header_notice_num" wrapid="note1" count="5" subcount="5" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/toolbar.js"></script>
     <!--new top-->
   
    <link href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ask_float_block.css" type="text/css" rel="stylesheet">
    <script language="JavaScript" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/wmd.js"></script>
    <script language="JavaScript" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/showdown.js"></script>
    <script language="JavaScript" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/prettify.js"></script>
    <script language="JavaScript" type="text/javascript" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ask_float_block.js"></script>



<div id="tag-suggest-pop" style="display: block;">
  <div class="relative">
    <div class="close"></div>
    <div class="content"><div><span>更多相关资源：</span><a href="http://www.csdn.net/tag/java" title="关于 java 的主题" target="_blank">java</a><a href="http://www.csdn.net/tag/exception" title="关于 exception 的主题" target="_blank">exception</a></div></div>
  </div>
</div><link rel="stylesheet" type="text/css" media="screen" href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/ask_float_fonts_css-6b30a53970eb5c3a2a045e3df585b475.css"><div data-mod="popu_64" class="tracking-ad" chg-blk="0"><a id="com-ask-float-block" title="提问按钮" style="top:436px"></a><a id="com-quick-reply" title="快速回复" style="top:477px"></a><a id="com-d-top-a" style="top: 518px; display: block;" title="返回顶部" onclick=""></a> </div><div class="pop_edit ask_second comm_ask_second"><h3>提问</h3><span class="ask_float_span">您的问题将会被发布在“<a class="ask_float_channel" href="http://ask.csdn.net/" target="_blank" style="cursor:pointer">技术问答</a>”频道</span><a href="http://blog.csdn.net/hguisu/article/details/6155636#" nodetype="close" class="close">×</a><div class="context"><div class="err_div"><span class="err_ico"></span><span class="err_txt">该问题已存在，请勿重复提问</span></div><div class="input_div"><input id="askInputSecond" type="text" style="font-size:14px;" placeholder="问题标题"></div><div class="cm_box"><div class="cm_dialog"></div> <div class="pop_cm cm_add_link"><input type="text" placeholder="链接内容" id="af_cm_link_txt"><input type="text" placeholder="链接地址" id="af_cm_link_url"><input type="text" placeholder="链接提示" id="af_cm_link_tit"><div class="text-right"><span class="btn btn-default btn-sm" id="add_link_btn">插入链接</span> </div> </div><div class="pop_cm cm_add_img"><div class="nav-tabs"><a class="img_tab active" href="http://blog.csdn.net/hguisu/article/details/6155636#tab_upload">本地上传</a><a class="img_tab" href="http://blog.csdn.net/hguisu/article/details/6155636#tab_weburl">网络图片</a></div><div class="tab_panel active" id="tab_upload"><div class="set_img"><iframe src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/upload.html"></iframe></div></div><div class="tab_panel" id="tab_weburl"><input type="text" placeholder="图片地址" id="af_cm_img_url"><input type="text" placeholder="图片说明" id="af_cm_img_alt"><div class="text-right"><span class="btn btn-default btn-sm" id="add_img_btn">插入图片</span> </div></div> </div></div> <textarea id="editor_all" rows="8" style="display: none;"></textarea><div class="editor-toolbar"><i class="separator">|</i><a class="icon-headline" title="标题一（Ctrl+Alt+1）"></a><a class="icon-heading" title="标题二（Ctrl+Alt+2）"></a><a class="icon-bold" title="粗体（Ctrl+B）"></a><a class="icon-italic" title="斜体（Ctrl+I）"></a><i class="separator">|</i><a class="icon-quote-left" title="引用（Ctrl+’）"></a><a class="icon-code" title="插入代码片（Ctrl+,）"></a><a class="icon-list-ul" title="无序列表（Ctrl+L）"></a><a class="icon-list-ol" title="有序列表（Ctrl+Alt+L）"></a><i class="separator">|</i><a class="icon-link" title="添加链接（Ctrl+K）"></a><a class="icon-picture" title="添加图片（Ctrl+Alt+I）"></a><i class="separator">|</i><a class="icon-reply" title="撤退（Ctrl+Z）"></a><a class="icon-share-alt" title="前进（Ctrl+Shift+Z）"></a><i class="separator">|</i><a class="icon-info" href="http://ask.csdn.net/pages/markdown" target="_blank" title="markdown语法参考"></a><a class="icon-preview" title="预览"></a><i class="separator">|</i></div><div class="CodeMirror cm-s-paper CodeMirror-focused"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; padding: 0px; width: 1000px; height: 1em; outline: none; font-size: 4px;"></textarea></div><div class="CodeMirror-hscrollbar"><div style="height: 1px;"></div></div><div class="CodeMirror-vscrollbar"><div style="width: 1px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="min-width: 33px;"><div style="position: relative;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre>&nbsp;<span style="display: inline-block; width: 1px; margin-right: -1px;">&nbsp;</span></pre></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"></div><div class="CodeMirror-cursor" style="">&nbsp;</div><div class="CodeMirror-cursor CodeMirror-secondarycursor" style="">&nbsp;</div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px;"></div><div class="CodeMirror-gutters" style="display: none;"></div></div></div><div class="editor-statusbar"><span class="lines">0</span><span class="words">0</span><span class="cursor">0:0</span></div><div class="div_tags clearfix"><div id="divSearchTags" class="tags_con"><input type="text"></div><input type="hidden" name="txtSearchTags"></div><div id="ask2_tagRecomm_div" class="drt_tagRecomm tracking-ad" data-mod="popu_73"><span class="drt_tit">推荐标签：</span></div></div><div class="success"><div class="left_area"><input id="chk_cb" type="checkbox"><span class="wyxs">我要悬赏</span><input id="cb_num" class="cb_num" readonly="true"><span class="phib_rii"><span> 币</span></span></div><a href="http://blog.csdn.net/hguisu/article/details/6155636#" nodetype="cancel" class="cancel">取消</a><a href="http://blog.csdn.net/hguisu/article/details/6155636#" nodetype="ok" class="ok">发布</a></div></div><div id="common_ask_div_sc" class="searchContainer"><div class="sTitle">可能存在类似的问题：</div><div class="sFooter"><a class="sFirstNewAsk">我想提一个新问题</a></div></div><style type="text/css" id="xnSmartBarCacheCSSID">

.baiduServiceBottomBar.noDis{display:none !important}.baiduServiceBottomBar.iphoneDevice>ul>li .count{font-size:10px;line-height:12px;height:12px;padding:0px 2px;top:-3px;right:-8px;box-sizing:border-box;font-family:Arial, Helvetica, sans-serif;text-shadow:none;outline:none}.baiduServiceBottomBar.hackIFrame iframe{top:0px;-webkit-transform:translateZ(5px);transform:translateZ(5px)}.baiduServiceBottomBar{overflow:visible;line-height:1;border-top:1px solid #c0c0c0;position:fixed;z-index:200;width:100%;bottom:0px;background-color:rgba(242,242,242,0.94);background-image:-moz-linear-gradient(rgba(248,248,248,0.94), rgba(242,242,242,0.94));background-image:-o-linear-gradient(rgba(248,248,248,0.94), rgba(242,242,242,0.94));background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(248,248,248,0.94)), color-stop(1, rgba(242,242,242,0.94)));background-image:-webkit-linear-gradient(rgba(248,248,248,0.94), rgba(242,242,242,0.94));background-image:-ms-linear-gradient(rgba(248,248,248,0.94), rgba(242,242,242,0.94));background-image:linear-gradient(rgba(248,248,248,0.94), rgba(242,242,242,0.94))}.baiduServiceBottomBar div{overflow:visible}.baiduServiceBottomBar div,.baiduServiceBottomBar span,.baiduServiceBottomBar object,.baiduServiceBottomBar iframe,.baiduServiceBottomBar h1,.baiduServiceBottomBar h2,.baiduServiceBottomBar h3,.baiduServiceBottomBar h4,.baiduServiceBottomBar h5,.baiduServiceBottomBar h6,.baiduServiceBottomBar p,.baiduServiceBottomBar a,.baiduServiceBottomBar em,.baiduServiceBottomBar img,.baiduServiceBottomBar b,.baiduServiceBottomBar i,.baiduServiceBottomBar dl,.baiduServiceBottomBar dt,.baiduServiceBottomBar dd,.baiduServiceBottomBar ol,.baiduServiceBottomBar ul,.baiduServiceBottomBar li,.baiduServiceBottomBar fieldset,.baiduServiceBottomBar form,.baiduServiceBottomBar label,.baiduServiceBottomBar table,.baiduServiceBottomBar caption,.baiduServiceBottomBar tbody,.baiduServiceBottomBar tfoot,.baiduServiceBottomBar thead,.baiduServiceBottomBar tr,.baiduServiceBottomBar th,.baiduServiceBottomBar td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline}.baiduServiceBottomBar p,.baiduServiceBottomBar div,.baiduServiceBottomBar h1,.baiduServiceBottomBar h2,.baiduServiceBottomBar h3,.baiduServiceBottomBar h4,.baiduServiceBottomBar h5,.baiduServiceBottomBar h6{-webkit-text-size-adjust:none}.baiduServiceBottomBar ul,.baiduServiceBottomBar li,.baiduServiceBottomBar a{vertical-align:middle}.baiduServiceBottomBar ol,.baiduServiceBottomBar ul{list-style:none;overflow:visible}.baiduServiceBottomBar .qingIcon{width:22px;height:22px;background-image:url("");margin:10px auto;background-size:100% 100%}.baiduServiceBottomBar .qingBtn{width:48px;height:48px;background-color:#f8f8f8;border:1px solid #ddd}.baiduServiceBottomBar .qingIcon,.baiduServiceBottomBar .qingBtn{display:block}.baiduServiceBottomBar *{vertical-align:middle;box-sizing:border-box}.baiduServiceBottomBar .baidu-xn-pop-parent{position:relative}.baiduServiceBottomBar .baidu-xn-pop-container{position:absolute;bottom:100%;display:none;z-index:-90;width:113%;background-color:rgba(255,255,255,0.94);background-image:-moz-linear-gradient(rgba(255,255,255,0.94), rgba(255,255,255,0.94));background-image:-o-linear-gradient(rgba(255,255,255,0.94), rgba(255,255,255,0.94));background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(255,255,255,0.94)), color-stop(1, rgba(255,255,255,0.94)));background-image:-webkit-linear-gradient(rgba(255,255,255,0.94), rgba(255,255,255,0.94));background-image:-ms-linear-gradient(rgba(255,255,255,0.94), rgba(255,255,255,0.94));background-image:linear-gradient(rgba(255,255,255,0.94), rgba(255,255,255,0.94));left:initial !important;margin-left:-7px;border:1px solid #c0c0c0;border-radius:2px;box-shadow:0px 0px 4px 1px rgba(0,0,0,0.12);margin-bottom:12px;-webkit-transform:scale(1)}.baiduServiceBottomBar .baidu-xn-pop-container ul,.baiduServiceBottomBar .baidu-xn-pop-container li{list-style:none}.baiduServiceBottomBar .baidu-xn-pop-container ul{padding:0px 9px;height:auto}.baiduServiceBottomBar .baidu-xn-pop-container ul>li:not(:last-of-type){border-bottom:1px solid #dddddd}.baiduServiceBottomBar .baidu-xn-pop-container li.vote{height:43px}.baiduServiceBottomBar .baidu-xn-pop-container ul>li{height:36px}.baiduServiceBottomBar .baidu-xn-pop-container ul>li a{padding:1px 0;font-size:14px}.baiduServiceBottomBar .baidu-xn-pop-container.show,.baiduServiceBottomBar .show>.baidu-xn-pop-container{display:block;z-index:-90}.baiduServiceBottomBar .noDis{display:none !important}.baiduServiceBottomBar a{text-decoration:none;color:#001526}.baiduServiceBottomBar>ul{display:-webkit-box;display:-ms-flexbox;display:-moz-box;display:box;width:100%;list-style-type:none;padding:0px;margin:0px;-webkit-box-pack:center;-webkit-box-align:center;box-pack:center;box-align:center;border:0 #fafafb solid;border-width:1px 0 0 1px}.baiduServiceBottomBar>ul>li{display:block;width:3em;-webkit-box-flex:1;flex:1;-ms-flex:1;-moz-box-flex:1;text-align:center;font-size:10px}.baiduServiceBottomBar>ul>li a{font-size:16px;padding:6px 0px 4px;display:inline-block;display:inline-block;width:100%;line-height:34px;height:43px;text-align:center}.baiduServiceBottomBar>ul>li a p>span.text-char{text-shadow:0 1px #fff}.baiduServiceBottomBar>ul>li .icon{width:18px;height:18px;display:block;margin:0px auto 4px;background-size:100% 100%;vertical-align:middle;position:relative}.baiduServiceBottomBar>ul>li .count-outer{position:relative;width:auto;display:inline-block;line-height:inherit}.baiduServiceBottomBar>ul>li .count{background-color:#f43b3b;color:#fff;border-radius:1px;padding:0px 2px;position:absolute;font-size:10px;line-height:12px;height:12px;top:-3px;right:-10px;font-style:normal;text-shadow:none;outline:none}.baiduServiceBottomBar>ul>li .baidu-xn-pop-container .count{top:3px}.baiduServiceBottomBar>ul li.showMoreBtn{display:none;position:relative}.baiduServiceBottomBar>ul .comment .count{right:-9px}.baiduServiceBottomBar>ul .pop-tip{-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg);width:6px;height:6px;z-index:300;top:-15px;left:-55%;position:absolute;border:1px solid #c0c0c0;background-color:rgba(255,255,255,0.94);display:none}.baiduServiceBottomBar>ul .pop-tip.align-right{margin-left:100%;border-left:0px;border-top:0px}@media only screen and (max-width: 400px){.baiduServiceBottomBar .show-more-buttons>li:nth-of-type(n+4),.baiduServiceBottomBar .show-more-buttons-lg>li:nth-of-type(n+4){display:none}.baiduServiceBottomBar .show-more-buttons>li.showMoreBtn,.baiduServiceBottomBar .show-more-buttons-lg>li.showMoreBtn{display:block}}@media only screen and (min-width: 400px) and (max-width: 480px){.baiduServiceBottomBar .show-more-buttons-lg>li:nth-of-type(n+5){display:none}.baiduServiceBottomBar .show-more-buttons-lg>li.showMoreBtn{display:block}}@media only screen and (max-device-width: 600px){.baiduServiceBottomBar #mobile-phone-detector{display:block}}.baiduServiceBottomBar [data-action=ecomBottomBar-vote]{position:relative}.baiduServiceBottomBar [data-action=ecomBottomBar-vote] .bd_vote{position:absolute;z-index:1;height:100%;width:100%;top:0px}.baiduServiceBottomBar [data-action=ecomBottomBar-vote] .text-char{display:inline-block;-webkit-transform:translateZ(0px);transform:translateZ(0px)}.baiduServiceBottomBar [data-action=ecomBottomBar-vote] .bd_vote iframe{position:relative}.baiduServiceBottomBar>ul>li:last-of-type .baidu-xn-pop-container{right:10px}.baiduServiceBottomBar>ul>li:first-of-type .baidu-xn-pop-container{left:8px !important;margin-left:0px}.baiduServiceBottomBar .baidu-xn-pop-parent:after{position:absolute;top:0px;left:50%;width:12px;height:3px;-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid #c0c0c0;border-left:0px;border-right:0px;margin:6px 0px 6px -6px;content:""}.baiduServiceBottomBar .qingBtn{display:none}.baiduServiceBottomBar.showQingIconStyle.hideContent{border-top:transparent;width:auto}.baiduServiceBottomBar.showQingIconStyle.hideContent .qingBtn{display:block}.baiduServiceBottomBar.showQingIconStyle.hideContent .icon-container{display:none}.baiduServiceBottomBar.showQingIconStyle{display:-webkit-box;display:-ms-flexbox;display:-moz-box;-webkit-box-pack:center;-webkit-box-align:center;box-pack:center;box-align:center}.baiduServiceBottomBar.showQingIconStyle .qingBtn{display:block}.baiduServiceBottomBar.showQingIconStyle>ul>li:first-of-type .baidu-xn-pop-container{left:initial !important;margin-left:-10%}.baiduServiceBottomBar.showQingIconStyle [data-action=ecomBottomBar-showMore]{max-width:50px}.baiduServiceBottomBar.showQingIconStyle [data-action=ecomBottomBar-showMore] .baidu-xn-pop-container{width:180%}.baiduServiceBottomBar.showQingIconStyle [data-action=ecomBottomBar-showMore] .pop-tip.align-right{margin-left:120%}.baiduServiceBottomBar.showQingIconStyle.showContent{width:100%}.baiduServiceBottomBar.showQingIconStyle.showContent .qingBtn{border:1px solid transparent;border-right:1px solid #cdcdcd}.baiduServiceBottomBar.showQingIconStyle.showContent .qingIcon{background-image:url()}.baiduServiceBottomBar.showQingIconStyle.showContent .icon-container{display:-webkit-box;display:-ms-flexbox;display:-moz-box;dislay:box;-webkit-box-flex:1;flex:1;-ms-flex:1;-moz-box-flex:1}.baiduServiceBottomBar.double-scale>ul>li a{line-height:68px;height:86px;font-size:32px;padding:12px 0 4px}.baiduServiceBottomBar.double-scale>ul>li .baidu-xn-pop-container{width:113%}.baiduServiceBottomBar.double-scale>ul>li .baidu-xn-pop-container ul{padding:0px 18px}.baiduServiceBottomBar.double-scale>ul>li .baidu-xn-pop-container ul>li{height:72px;line-height:60px;width:100%}.baiduServiceBottomBar.double-scale>ul>li .baidu-xn-pop-container ul>li a{padding:0px;line-height:72px;height:72px}.baiduServiceBottomBar.double-scale>ul>li .count{font-size:20px;line-height:20px;height:20px;padding:0 6px;top:6px;right:-20px;text-shadow:none;outline:none;border-radius:4px}.baiduServiceBottomBar.double-scale .baidu-xn-pop-parent:after{width:24px;height:6px;margin:12px 0 12px -12px;content:""}@media only screen and (max-width: 800px){.baiduServiceBottomBar.double-scale .show-more-buttons>li:nth-of-type(n+4),.baiduServiceBottomBar.double-scale .show-more-buttons-lg>li:nth-of-type(n+4){display:none}.baiduServiceBottomBar.double-scale .show-more-buttons>li.showMoreBtn,.baiduServiceBottomBar.double-scale .show-more-buttons-lg>li.showMoreBtn{display:block}}@media only screen and (min-width: 800px) and (max-width: 960px){.baiduServiceBottomBar.double-scale .show-more-buttons-lg>li:nth-of-type(n+5){display:none}.baiduServiceBottomBar.double-scale .show-more-buttons-lg>li.showMoreBtn{display:block}}.smb-user-guide-wrapper{position:fixed;z-index:9999;background:rgba(15,15,15,0.8);top:83px;width:238px;height:195px;left:50%;margin-left:-119px;border-radius:10px;font-size:14px;font-family:sans-serif}.smb-user-guide-wrapper .bg-pic{margin-top:24px;height:131px;background:url(http://m.baidu.com/static/search/siteapp/lego/use_guide.png) center no-repeat;background-size:208px 131px}.smb-user-guide-wrapper .queryX{position:absolute;left:44px;top:90px}.smb-user-guide-wrapper .closeX{display:block;margin:8px auto;color:#fff;width:110px;height:25px;line-height:25px;text-align:center}.baiduServiceBottomBar-toast-container{position:fixed;z-index:99999999;width:100%;bottom:50px;text-align:center}.baiduServiceBottomBar-toast-container .toast-text{min-width:40%;max-width:80%;overflow:hidden;word-break:break-all;word-wrap:nowrap;text-overflow:ellipsis;background-color:rgba(0,0,0,0.75);opacity:0;-webkit-transition:opacity 2s linear 0s;border-radius:5px;color:#fff;padding:10px;margin:0px auto;font-size:16px}.baiduServiceBottomBar-toast-container.show .toast-text{opacity:1}.baiduServiceBottomBar-toast-container.noDis{display:none !important}body,html{padding:0px;margin:0px}

/**
 * 用于将 css 以内联 js 的形式插入到页面中去
 */
</style><script type="text/javascript" charset="utf-8" src="http://127.0.0.1:7777/getcuid?callback=xnJSONP093881" defer=""></script><div class="baiduServiceBottomBar noDis"><a class="qingBtn" data-action="ecomBottomBar-iconBtn" onclick="javascript:void(0);"><i class="qingIcon"></i></a><ul class="showCount-3 icon-container"><li><a data-action="ecomBottomBar-comment" onclick="javascript:void(0);" class="hackTJMark"><p class="count-outer"><span class="text-char">评价</span><span class="count" style="right: 0px;">21</span></p></a></li><li><a data-action="qingBottomBarShare" onclick="javascript:void(0);"><p class="count-outer"><span class="text-char">分享</span><span class="count noDis"></span></p></a></li><li><a data-action="ecomBottomBar-vote" onclick="javascript:void(0);"><p class="count-outer"><span class="text-char">赞</span><span class="count" style="right: 0px;">216</span></p><div class="bd_vote" data-inited="1"><iframe id="vote142845513050013" style="border: none; width: 100%; height: 100%; display: block;" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/like.html"></iframe></div></a></li><li class="showMoreBtn baidu-xn-pop-parent" data-action="ecomBottomBar-showMore"><a onclick="javascript:void(0);">更多</a><div class="noDis"><div class="baidu-xn-pop-container"><div class="pop-content"><ul></ul></div></div><div class="pop-tip align-right"></div></div></li></ul><!-- hack form mobile phone detect --><span id="mobile-phone-detector"></span></div><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/vote.js" async=""></script><iframe src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/langchao-Cloud-daohangtiaoxia-banner-960-90-30k.html" style="width: 1px; height: 1px; position: absolute; visibility: hidden;"></iframe><link href="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/message_pop.css" rel="stylesheet" type="text/css"><div id="_popup_msg_container" style="display: block;">

<div wistate="max" id="im_popupWindow_miniMsg" class="im_popupWindow" style="display: none; height: 0px;">
	<h6 class="wi_draggable"><span>技术文章一周热点</span><a onclick="_message_tips_pop(&#39;down&#39;);return false;"><img alt="close" class="founctionpic3" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/pic_close.gif"></a></h6>
    <div id="im_popupWindow_miniMsgContent" class="wi_content">
		<style type="text/css">
<!--
	#im2009 { position:relative; width:280px;  background-color:#FEF9F5; overflow:hidden;}
	#im2009 UL{ width:100%;  float:left; margin-left:0; padding:5px 10px; overflow:hidden;}
        .blue { line-height:120%;}
	.blue A:link { color:#100cff; text-decoration:none;}
	.blue A:visited { color:#100cff; text-decoration:none;}
	.blue A:active { color:#100cff; text-decoration:none;}
	.blue A:hover { color:#100cff; text-decoration:none;}
	
	.bottom { margin-bottom:0px; height:40px; padding:5px}
	.bottom A:link { color:#FF9900; text-decoration:none; font-size:12px;}
	.bottom A:visited { color:#FF9900; text-decoration:none; font-size:12px;}
	.bottom A:active { color:#FF9900; text-decoration:none; font-size:12px;}
	.bottom A:hover { color:#FF9900; text-decoration:none; font-size:12px;}
-->
        .Adela li { margin-top:0px; margin-bottom:5px; }
        .bottom { margin-top:10px; }
        </style>

        <div id="im2009" style="left: 0px; top: 0px; height: 180px">
            <ul class="Adela">      
               <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?page=3" target="_blank">1、  Azure 移动服务入门之iOS教程</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?page=3" target="_blank">2、  Azure 移动服务入门之Android教程
</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?page=3" target="_blank">3、  Azure 移动服务入门之HTML教程 </a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=2" target="_blank">4、  阿里云至Azure的Linux VM迁移</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=2" target="_blank">5、  中国 Azure 应用程序的开发人员注意事项</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=2" target="_blank">6、  一张图让你认识 Azure</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=1" target="_blank">7、   设计示例：Azure 中的 Internet 网站</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=1" target="_blank">8、 认识云计算</a></li>
        <li class="blue"><a href="http://azure.csdn.net/m/zone/azure/technical_file?&page=1" target="_blank">9、  建立自己的网站</a></li>   

       </ul>
	</div>
<div class="content_qq"><span onclick="window.open(&#39;&#39;)" target="_blank"><font color="red"></font></span>
 </div>
 
 
</div>
</div></div><img src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/count_new.php" style="display: none;"><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(1)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(2)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(3)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(4)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(5)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(6)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(7)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(8)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(9)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(10)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(11)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(12)" defer=""></script><script type="text/javascript" charset="utf-8" src="./深入理解java异常处理机制 - guisu，程序人生。 逆水行舟，不进则退。 - 博客频道 - CSDN.NET_files/info(13)" defer=""></script></body></html>